library(tidyverse)
library(plotly)
library(sf)
library(mapview)
library(tigris)
library(censusapi)
library(leaflet)
library(lehdr)
options(
tigris_class = "sf",
tigris_use_cache = TRUE
)
Sys.setenv(CENSUS_KEY="10dcd73d7c043e91bac9fb8d3989cbff54b08790")
Here I obtain various demographic data, including income (percent below 50% and 80% of area median income), vehicle ownership, age, English language ability, and occupants per room.
# obtain the saved census data
setwd("~/Documents/2020 Spring Quarter/CEE 218Z")
acs_vars = readRDS("censusData2018_acs_acs5.rds")
setwd("~/Documents/2020 Spring Quarter/CEE 218Z/covid19")
# load in income data - code adapted from other students
sj_median_income_by_block <-
getCensus(
name = "acs/acs5",
vintage = 2018,
region = "block group:*",
regionin = "state:06+county:085",
vars = "B19013_001E"
) %>%
mutate(
blockgroup =
paste0(state,county,tract,block_group)
) %>%
select_if(!names(.) %in% c("GEO_ID","state","county","tract","block_group","NAME")) %>%
rename(
Median_Income = B19013_001E
) %>%
filter(!is.na(Median_Income)) %>%
left_join(sj_blockgroups, by = c("blockgroup" = "GEOID")) %>% #this code gives each blockgroup a district designation
filter(
!is.na(DISTRICTS)
) %>%
# this code joins our census data with the social distancing data, processed as shown below
left_join(sj_socialdistancing %>%
filter(weekend == F) %>%
filter(date > shelter_start) %>%
group_by(origin_census_block_group) %>%
summarize(
completely_home_device_count = sum(completely_home_device_count),
device_count = sum(device_count)) %>%
mutate(`% Completely at Home` = (completely_home_device_count/device_count*100) %>% round(1),
`% not completely at home` = (100 - `% Completely at Home`)),
by = c("blockgroup" = "origin_census_block_group")
) %>%
filter(
!is.na(device_count)
) %>%
left_join(sj_pre_sd_at_home_average %>% dplyr::select(origin_census_block_group, `% Completely at Home Pre Shelter`, `% not completely at home pre shelter`), by = c("blockgroup" = "origin_census_block_group"))
sj_ami_by_block <-
getCensus(
name = "acs/acs5",
vintage = 2018,
region = "block group:*",
regionin = "state:06+county:085",
vars = "group(B19001)"
) %>%
mutate(
blockgroup =
paste0(state,county,tract,block_group)
) %>%
select_if(!names(.) %in% c("GEO_ID","state","county","tract","block_group","NAME")) %>%
dplyr::select(-c(contains("EA"),contains("MA"),contains("M"))) %>%
group_by(blockgroup) %>%
summarize(
Total = B19001_001E,
`Under 75,000` = sum(B19001_002E, B19001_003E, B19001_004E, B19001_005E, B19001_006E, B19001_007E, B19001_008E, B19001_009E, B19001_010E, B19001_011E, B19001_012E),
#sum(lapply(2:12, function(x) as.name(paste0("B19001_00",x,"E"))))
`Under 100,000` = sum(B19001_002E, B19001_003E, B19001_004E, B19001_005E, B19001_006E, B19001_007E, B19001_008E, B19001_009E, B19001_010E, B19001_011E, B19001_012E, B19001_013E),
`Under 125,000` = sum(B19001_002E, B19001_003E, B19001_004E, B19001_005E, B19001_006E, B19001_007E, B19001_008E, B19001_009E, B19001_010E, B19001_011E, B19001_012E, B19001_013E, B19001_014E)
) %>%
mutate(
`% under 75,000` = `Under 75,000` / Total * 100,
`% over 75,000` = (100 - `% under 75,000`),
`% under 100,000` = `Under 100,000` / Total * 100,
`% over 100,000` = (100 - `% under 100,000`),
`% under 125,000` = `Under 125,000` / Total * 100,
`% over 125,000` = (100 - `% under 125,000`),
) %>%
left_join(sj_median_income_by_block %>% dplyr::select(-Median_Income)
) %>%
filter(!is.na(device_count))
# loading in language data - code adapted from other students
sj_lang_by_block <-
getCensus(
name = "acs/acs5",
vintage = 2018,
region = "block group:*",
regionin = "state:06+county:085",
vars = "group(B16004)"
) %>%
mutate(
blockgroup =
paste0(state,county,tract,block_group)
) %>%
select_if(!names(.) %in% c("GEO_ID","state","county","tract","block_group","NAME")) %>%
select(-c(contains("EA"),contains("MA"),contains("M"))) %>%
gather(
key = "variable",
value = "estimate",
- blockgroup
) %>%
left_join(acs_vars, by = c("variable" = "name")) %>%
mutate(
tier = substr(label,lapply(label, function(x) max(unlist(gregexpr('!!',x)))+2),nchar(label))
) %>%
filter(tier %in% c('Speak English "not well"',
'Speak English "not at all"',
'Total', 'Speak Spanish',
'Speak Asian and Pacific Island languages')) %>%
group_by(blockgroup, tier) %>%
summarise(
estimate1 = sum(estimate)
) %>%
spread(
key = "tier",
value = "estimate1"
) %>%
mutate(
`% speaking english < well` = (`Speak English "not well"` + `Speak English "not at all"`) / Total * 100,
`% speaking english > well` = (100 - `% speaking english < well`),
`% speaking spanish` = (`Speak Spanish`/ Total) * 100,
`% not speaking spanish` = (100 - `% speaking spanish`),
`% speaking api` = (`Speak Asian and Pacific Island languages` / Total) * 100
) %>%
left_join(sj_median_income_by_block %>% dplyr::select(-Median_Income)) %>%
filter(!is.na(device_count)) %>%
mutate(log_perc = log(`% speaking english < well`))
# loading in age data - specifically looking at percentage 65+ and percentage <30
sj_age_by_block <- getCensus(
name = "acs/acs5",
vintage = 2018,
region = "block group:*",
regionin = "state:06+county:085",
vars = "group(B01001)"
) %>%
mutate(
blockgroup =
paste0(state,county,tract,block_group)
) %>%
select_if(!names(.) %in% c("GEO_ID","state","county","tract","block_group","NAME")) %>%
select(-c(contains("EA"),contains("MA"),contains("M"))) %>%
gather(
key = "variable",
value = "estimate",
- blockgroup
) %>%
mutate(
label = acs_vars$label[match(variable,acs_vars$name)]
) %>%
select(-variable) %>%
separate(
label,
into = c(NA,NA,"sex","age"),
sep = "!!"
) %>% filter(!is.na(age)) %>%
mutate(elderly = ifelse(age %in% c("65 and 66 years", "67 to 69 years", "70 to 74 years", "75 to 79 years", "80 to 84 years", "85 years and over"), estimate, NA), `less than 30` = ifelse(age %in% c("Under 5 years", "5 to 9 years", "10 to 14 years", "15 to 17 years", "18 and 19 years", "20 years", "21 years", "22 to 24 years", "25 to 29 years"), estimate, NA)) %>%
group_by(blockgroup) %>%
summarize(elderly = sum(elderly, na.rm = T), `less than 30` = sum(`less than 30`, na.rm = T), total = sum(estimate, na.rm = T)) %>%
mutate(`percent elderly` = elderly*100 / total, `percent less than 30` = `less than 30`*100 / total, `percent nonelderly` = (100 - `percent elderly`)) %>%
left_join(sj_median_income_by_block %>% dplyr::select(-Median_Income)) %>%
filter(!is.na(device_count))
# get data on vehicles available as vehicles allocation
sj_vehicles_by_block <- getCensus(
name = "acs/acs5",
vintage = 2018,
region = "block group:*",
regionin = "state:06+county:085",
vars = "group(B992512)"
) %>%
mutate(
blockgroup =
paste0(state,county,tract,block_group)
) %>%
select_if(!names(.) %in% c("GEO_ID","state","county","tract","block_group","NAME")) %>%
select(-c(contains("EA"),contains("MA"),contains("M"))) %>%
dplyr::select(B992512_001E, blockgroup) %>%
rename(total_vehicles = B992512_001E, blockgroup = blockgroup) %>%
left_join(sj_age_by_block %>% dplyr::select_if(!names(.) %in% c("elderly", "percent elderly", "less than 30", "percent less than 30"))) %>%
mutate(`vehicles per capita` = total_vehicles / total) %>%
filter(!is.na(device_count))
# also get data on vehicles available as households without a vehicle
sj_no_vehicles_by_block <- getCensus(
name = "acs/acs5",
vintage = 2018,
region = "block group:*",
regionin = "state:06+county:085",
vars = "group(B25044)"
) %>%
mutate(
blockgroup =
paste0(state,county,tract,block_group)
) %>%
select_if(!names(.) %in% c("GEO_ID","state","county","tract","block_group","NAME")) %>%
select(-c(contains("EA"),contains("MA"),contains("M"))) %>%
gather(key = "variable", value = "estimate", -blockgroup) %>%
mutate(label = acs_vars$label[match(variable,acs_vars$name)]) %>%
select(-variable) %>%
separate(label, into = c(NA, NA, NA,"vehicles"), sep = "!!") %>%
filter(!is.na(vehicles)) %>%
group_by(blockgroup, vehicles) %>%
summarize(grouped_vehicles = sum(estimate)) %>%
spread(key = vehicles, value = grouped_vehicles) %>%
mutate(total_nums = `1 vehicle available` + `2 vehicles available` + `3 vehicles available` + `4 vehicles available` + `5 or more vehicles available` + `No vehicle available`, `percent no vehicles` = `No vehicle available`*100 / total_nums, `percent with vehicles` = (100-`percent no vehicles`)) %>%
left_join(sj_age_by_block %>% dplyr::select_if(!names(.) %in% c("elderly", "percent elderly", "less than 30", "percent less than 30"))) %>%
filter(!is.na(device_count))
# get data on occupants per room
sj_occupants_per_room_by_block <- getCensus(
name = "acs/acs5",
vintage = 2018,
region = "block group:*",
regionin = "state:06+county:085",
vars = "group(B25014)"
) %>%
mutate(
blockgroup =
paste0(state,county,tract,block_group)
) %>%
select_if(!names(.) %in% c("GEO_ID","state","county","tract","block_group","NAME")) %>%
select(-c(contains("EA"),contains("MA"),contains("M"))) %>%
gather(key = "variable", value = "estimate", -blockgroup) %>%
mutate(label = acs_vars$label[match(variable,acs_vars$name)]) %>%
select(-variable) %>%
separate(label, into = c(NA, NA, NA,"occupants per room"), sep = "!!") %>%
filter(!is.na(`occupants per room`)) %>%
group_by(blockgroup, `occupants per room`) %>%
summarize(estimate_tot = sum(estimate)) %>%
spread(key = `occupants per room`, value = estimate_tot) %>%
mutate(total_nums = `0.50 or less occupants per room` + `0.51 to 1.00 occupants per room` + `1.01 to 1.50 occupants per room` + `1.51 to 2.00 occupants per room` + `2.01 or more occupants per room`, `percent 1 or more` = (`1.01 to 1.50 occupants per room` + `1.51 to 2.00 occupants per room` + `2.01 or more occupants per room`) * 100/ total_nums, `percent less than 1` = (100-`percent 1 or more`)) %>%
left_join(sj_age_by_block %>% dplyr::select_if(!names(.) %in% c("elderly", "percent elderly", "less than 30", "percent less than 30"))) %>%
filter(!is.na(device_count))
In the plots below, I show the selected variables against percent of devices completely at home since the shelter-in-place order started, as well as against percent of devices pre-shelter-in-place for comparison.
# age
sj_age_by_block %>%
ggplot(aes(
x = `percent less than 30`,
y = `% not completely at home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of residents younger than 30",
y = "Percent devices leaving home on weekdays since shelter-in-place",
title = "San Jose: Social Distancing and Young Age Groups"
)
young_model <- lm(sj_age_by_block$`% not completely at home` ~ sj_age_by_block$`percent less than 30`)
summary(young_model)
##
## Call:
## lm(formula = sj_age_by_block$`% not completely at home` ~ sj_age_by_block$`percent less than 30`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -28.505 -4.978 -0.362 4.274 39.808
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 44.49223 1.51348 29.397 < 2e-16 ***
## sj_age_by_block$`percent less than 30` 0.17973 0.03836 4.685 3.51e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.299 on 567 degrees of freedom
## Multiple R-squared: 0.03726, Adjusted R-squared: 0.03557
## F-statistic: 21.95 on 1 and 567 DF, p-value: 3.513e-06
sj_age_by_block %>% filter(`percent elderly` < 50) %>% # get rid of extreme outliers
ggplot(aes(
x = `percent elderly`,
y = `% not completely at home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of residents 65 and older",
y = "Percent devices leaving home on weekdays since shelter-in-place",
title = "San Jose: Social Distancing and Elderly Population"
)
elderly_model <- lm(`% not completely at home` ~ `percent elderly`, sj_age_by_block %>% filter(`percent elderly` < 50))
summary(elderly_model)
##
## Call:
## lm(formula = `% not completely at home` ~ `percent elderly`,
## data = sj_age_by_block %>% filter(`percent elderly` < 50))
##
## Residuals:
## Min 1Q Median 3Q Max
## -28.542 -5.120 -0.472 4.248 36.658
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 53.65024 0.78297 68.52 <2e-16 ***
## `percent elderly` -0.17733 0.05406 -3.28 0.0011 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.361 on 564 degrees of freedom
## Multiple R-squared: 0.01872, Adjusted R-squared: 0.01698
## F-statistic: 10.76 on 1 and 564 DF, p-value: 0.001102
# compare this to pre-shelter-in-place behavior
sj_age_by_block %>%
ggplot(aes(
x = `percent less than 30`,
y = `% not completely at home pre shelter`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of residents younger than 30",
y = "Percent devices leaving home pre-shelter-in-place",
title = "San Jose: Staying at Home and Young Age Groups Pre Shelter-in-Place"
)
young_model2 <- lm(sj_age_by_block$`% not completely at home pre shelter` ~ sj_age_by_block$`percent less than 30`)
summary(young_model2)
##
## Call:
## lm(formula = sj_age_by_block$`% not completely at home pre shelter` ~
## sj_age_by_block$`percent less than 30`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -28.1939 -2.8160 -0.1557 2.9950 16.7071
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 81.87032 0.82253 99.53 < 2e-16 ***
## sj_age_by_block$`percent less than 30` -0.11072 0.02085 -5.31 1.57e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.51 on 567 degrees of freedom
## Multiple R-squared: 0.04738, Adjusted R-squared: 0.0457
## F-statistic: 28.2 on 1 and 567 DF, p-value: 1.573e-07
sj_age_by_block %>% filter(`percent elderly` < 50) %>% # get rid of extreme outliers
ggplot(aes(
x = `percent elderly`,
y = `% not completely at home pre shelter`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of residents 65 and older",
y = "Percent devices leaving home on weekdays pre-shelter-in-place",
title = "San Jose: Staying at Home and Elderly Population Pre Shelter-in-Place"
)
elderly_model2 <- lm(`% not completely at home pre shelter` ~ `percent elderly`, sj_age_by_block %>% filter(`percent elderly` < 50))
summary(elderly_model2)
##
## Call:
## lm(formula = `% not completely at home pre shelter` ~ `percent elderly`,
## data = sj_age_by_block %>% filter(`percent elderly` < 50))
##
## Residuals:
## Min 1Q Median 3Q Max
## -27.236 -2.830 -0.158 3.145 14.296
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 75.9045 0.4257 178.295 < 2e-16 ***
## `percent elderly` 0.1329 0.0294 4.522 7.47e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.546 on 564 degrees of freedom
## Multiple R-squared: 0.03499, Adjusted R-squared: 0.03328
## F-statistic: 20.45 on 1 and 564 DF, p-value: 7.466e-06
# income - less than $75000
sj_ami_by_block %>%
ggplot(aes(
x = `% over 75,000`,
y = `% not completely at home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of housholds with incomes over $75,000 (50% AMI) annually",
y = "Percent devices leaving home on weekdays since shelter-in-place",
title = "San Jose: Social Distancing and Households Above 50% AMI"
)
income_75_model <- lm(`% not completely at home` ~ `% over 75,000`, sj_ami_by_block)
summary(income_75_model)
##
## Call:
## lm(formula = `% not completely at home` ~ `% over 75,000`, data = sj_ami_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -21.389 -4.795 -0.606 4.185 34.925
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 64.35928 1.11518 57.71 <2e-16 ***
## `% over 75,000` -0.20909 0.01719 -12.16 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.444 on 566 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.2072, Adjusted R-squared: 0.2058
## F-statistic: 148 on 1 and 566 DF, p-value: < 2.2e-16
# income - less than $100000
sj_ami_by_block %>%
ggplot(aes(
x = `% over 100,000`,
y = `% not completely at home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of housholds with incomes over $100,000 (80% AMI) annually",
y = "Percent devices leaving home on weekdays since shelter-in-place",
title = "San Jose: Social Distancing and Households Below 80% AMI"
)
income_100_model <- lm(`% not completely at home` ~ `% over 100,000`, sj_ami_by_block)
summary(income_100_model)
##
## Call:
## lm(formula = `% not completely at home` ~ `% over 100,000`, data = sj_ami_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -20.762 -4.639 -0.500 4.176 33.309
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 61.78423 0.87244 70.82 <2e-16 ***
## `% over 100,000` -0.20475 0.01599 -12.80 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.362 on 566 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.2246, Adjusted R-squared: 0.2232
## F-statistic: 163.9 on 1 and 566 DF, p-value: < 2.2e-16
# income - less than $125000
sj_ami_by_block %>%
ggplot(aes(
x = `% over 125,000`,
y = `% not completely at home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of housholds with incomes over $125,000 annually",
y = "Percent devices leaving home on weekdays since shelter-in-place",
title = "San Jose: Social Distancing and Households Below $125,000"
)
income_125_model <- lm(`% not completely at home` ~ `% over 125,000`, sj_ami_by_block)
summary(income_125_model)
##
## Call:
## lm(formula = `% not completely at home` ~ `% over 125,000`, data = sj_ami_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -23.072 -4.669 -0.845 4.018 32.374
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 60.00338 0.73524 81.61 <2e-16 ***
## `% over 125,000` -0.21065 0.01623 -12.98 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.339 on 566 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.2294, Adjusted R-squared: 0.228
## F-statistic: 168.5 on 1 and 566 DF, p-value: < 2.2e-16
# compare to pre shelter in place
sj_ami_by_block %>%
ggplot(aes(
x = `% over 75,000`,
y = `% not completely at home pre shelter`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of housholds with incomes over $75,000 (50% AMI) annually",
y = "Percent devices leaving home on weekdays pre-shelter-in-place",
title = "San Jose: Staying at Home and Households Above 50% AMI Pre Shelter-in-Place"
)
income_75_model2 <- lm(`% not completely at home pre shelter` ~ `% over 75,000`, sj_ami_by_block)
summary(income_75_model2)
##
## Call:
## lm(formula = `% not completely at home pre shelter` ~ `% over 75,000`,
## data = sj_ami_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -28.4357 -2.7003 -0.1437 2.7764 16.6680
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 72.61447 0.65712 110.504 < 2e-16 ***
## `% over 75,000` 0.08029 0.01013 7.926 1.21e-14 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.386 on 566 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.09991, Adjusted R-squared: 0.09832
## F-statistic: 62.83 on 1 and 566 DF, p-value: 1.206e-14
# income - less than $100000
sj_ami_by_block %>%
ggplot(aes(
x = `% over 100,000`,
y = `% not completely at home pre shelter`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of housholds with incomes over $100,000 (80% AMI) annually",
y = "Percent devices leaving home on weekdays pre-shelter-in-place",
title = "San Jose: Staying Home and Households Below 80% AMI Pre Shelter-in-Place"
)
income_100_model2 <- lm(`% not completely at home pre shelter` ~ `% over 100,000`, sj_ami_by_block)
summary(income_100_model2)
##
## Call:
## lm(formula = `% not completely at home pre shelter` ~ `% over 100,000`,
## data = sj_ami_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -28.5034 -2.6406 0.0803 2.5599 16.9387
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 73.26132 0.51177 143.152 <2e-16 ***
## `% over 100,000` 0.08532 0.00938 9.096 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.319 on 566 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.1275, Adjusted R-squared: 0.126
## F-statistic: 82.73 on 1 and 566 DF, p-value: < 2.2e-16
# over 125000
sj_ami_by_block %>%
ggplot(aes(
x = `% over 125,000`,
y = `% not completely at home pre shelter`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of housholds with incomes over $125,000 annually",
y = "Percent devices leaving home on weekdays pre-shelter-in-place",
title = "San Jose: Social Distancing and Households Below $125,000 Pre Shelter-in-Place"
)
income_125_model2 <- lm(`% not completely at home pre shelter` ~ `% over 125,000`, sj_ami_by_block)
summary(income_125_model2)
##
## Call:
## lm(formula = `% not completely at home pre shelter` ~ `% over 125,000`,
## data = sj_ami_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -28.353 -2.556 0.022 2.522 16.560
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 73.640242 0.425069 173.2 <2e-16 ***
## `% over 125,000` 0.096607 0.009382 10.3 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.243 on 566 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.1578, Adjusted R-squared: 0.1563
## F-statistic: 106 on 1 and 566 DF, p-value: < 2.2e-16
# language
sj_lang_by_block %>%
ggplot(aes(
x = `% speaking english > well`,
y = `% not completely at home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of individuals speaking English well",
y = "Percent devices leaving home on weekdays since shelter-in-place",
title = "San Jose: Social Distancing and English Language Ability"
)
english_ability_model <- lm(`% not completely at home` ~ `% speaking english > well`, sj_lang_by_block)
summary(english_ability_model)
##
## Call:
## lm(formula = `% not completely at home` ~ `% speaking english > well`,
## data = sj_lang_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -25.467 -5.070 -0.542 3.887 39.230
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 67.28491 3.36107 20.019 < 2e-16 ***
## `% speaking english > well` -0.17915 0.03769 -4.754 2.53e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.294 on 567 degrees of freedom
## Multiple R-squared: 0.03833, Adjusted R-squared: 0.03663
## F-statistic: 22.6 on 1 and 567 DF, p-value: 2.534e-06
sj_lang_by_block %>%
ggplot(aes(
x = `% not speaking spanish`,
y = `% not completely at home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of individuals not speaking Spanish",
y = "Percent devices leaving home on weekdays since shelter-in-place",
title = "San Jose: Social Distancing and Spanish Language Ability"
)
spanish_speaking_model <- lm(`% not completely at home` ~ `% not speaking spanish`, sj_lang_by_block)
summary(spanish_speaking_model)
##
## Call:
## lm(formula = `% not completely at home` ~ `% not speaking spanish`,
## data = sj_lang_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -25.434 -4.585 -0.796 3.568 38.341
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 63.61990 1.32137 48.147 <2e-16 ***
## `% not speaking spanish` -0.15727 0.01646 -9.555 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.849 on 567 degrees of freedom
## Multiple R-squared: 0.1387, Adjusted R-squared: 0.1372
## F-statistic: 91.29 on 1 and 567 DF, p-value: < 2.2e-16
# compare to pre shelter in place
sj_lang_by_block %>%
ggplot(aes(
x = `% speaking english > well`,
y = `% not completely at home pre shelter`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of individuals speaking English well",
y = "Percent devices leaving home on weekdays pre-shelter-in-place",
title = "San Jose: Staying at Home and English Language Ability Pre Shelter-in-Place"
)
english_ability_model2 <- lm(`% not completely at home pre shelter` ~ `% speaking english > well`, sj_lang_by_block)
summary(english_ability_model2)
##
## Call:
## lm(formula = `% not completely at home pre shelter` ~ `% speaking english > well`,
## data = sj_lang_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -28.9364 -2.4342 0.0388 3.0316 12.3011
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 60.84131 1.73337 35.100 <2e-16 ***
## `% speaking english > well` 0.18913 0.01943 9.732 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.277 on 567 degrees of freedom
## Multiple R-squared: 0.1431, Adjusted R-squared: 0.1416
## F-statistic: 94.7 on 1 and 567 DF, p-value: < 2.2e-16
sj_lang_by_block %>%
ggplot(aes(
x = `% not speaking spanish`,
y = `% not completely at home pre shelter`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of individuals not speaking Spanish",
y = "Percent devices leaving home on weekdays pre shelter-in-place",
title = "San Jose: Staying at Home and Spanish Language Ability Pre Shelter-in-Place"
)
spanish_speaking_model2 <- lm(`% not completely at home pre shelter` ~ `% not speaking spanish`, sj_lang_by_block)
summary(spanish_speaking_model2)
##
## Call:
## lm(formula = `% not completely at home pre shelter` ~ `% not speaking spanish`,
## data = sj_lang_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -28.793 -2.540 -0.002 2.680 11.988
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 71.228200 0.726831 97.998 <2e-16 ***
## `% not speaking spanish` 0.082206 0.009054 9.079 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.318 on 567 degrees of freedom
## Multiple R-squared: 0.1269, Adjusted R-squared: 0.1254
## F-statistic: 82.43 on 1 and 567 DF, p-value: < 2.2e-16
# occupants per room
sj_occupants_per_room_by_block %>%
ggplot(aes(
x = `percent less than 1`,
y = `% not completely at home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of households with 1 or fewer occupant per room",
y = "Percent devices leaving home on weekdays since shelter-in-place",
title = "San Jose: Social Distancing and Room Occupancy"
)
occupants_model <- lm(`% not completely at home` ~ `percent less than 1`, sj_occupants_per_room_by_block)
summary(occupants_model)
##
## Call:
## lm(formula = `% not completely at home` ~ `percent less than 1`,
## data = sj_occupants_per_room_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -24.657 -4.937 -0.288 3.901 35.043
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 70.49553 2.95264 23.875 < 2e-16 ***
## `percent less than 1` -0.21239 0.03252 -6.532 1.45e-10 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.062 on 566 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.07009, Adjusted R-squared: 0.06845
## F-statistic: 42.66 on 1 and 566 DF, p-value: 1.451e-10
# compare to pre shelter in place
sj_occupants_per_room_by_block %>%
ggplot(aes(
x = `percent less than 1`,
y = `% not completely at home pre shelter`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of households with 1 or fewer occupant per room",
y = "Percent devices leaving home on weekdays pre shelter-in-place",
title = "San Jose: Staying at Home and Room Occupancy Pre Shelter-in-Place"
)
occupants_model2 <- lm(`% not completely at home pre shelter` ~ `percent less than 1`, sj_occupants_per_room_by_block)
summary(occupants_model2)
##
## Call:
## lm(formula = `% not completely at home pre shelter` ~ `percent less than 1`,
## data = sj_occupants_per_room_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -28.3246 -2.6506 -0.2808 2.7536 17.0509
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 62.88485 1.57437 39.943 <2e-16 ***
## `percent less than 1` 0.16329 0.01734 9.418 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.299 on 566 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.1355, Adjusted R-squared: 0.134
## F-statistic: 88.7 on 1 and 566 DF, p-value: < 2.2e-16
# vehicles
sj_vehicles_by_block %>%
ggplot(aes(
x = `vehicles per capita`,
y = `% not completely at home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Number of vehicles per capita",
y = "Percent devices leaving home on weekdays since shelter-in-place",
title = "San Jose: Social Distancing and Vehicles Per Capita"
)
# vehicles - percent with no vehicles
sj_no_vehicles_by_block %>%
ggplot(aes(
x = `percent with vehicles`,
y = `% not completely at home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of housholds with vehicles available",
y = "Percent devices leaving home on weekdays since shelter-in-place",
title = "San Jose: Social Distancing and Vehicle Availability"
)
vehicles_model <- lm(`% not completely at home` ~ `percent with vehicles`, sj_no_vehicles_by_block)
summary(vehicles_model)
##
## Call:
## lm(formula = `% not completely at home` ~ `percent with vehicles`,
## data = sj_no_vehicles_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -25.500 -5.226 -0.406 4.579 38.500
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 75.71497 5.14420 14.72 < 2e-16 ***
## `percent with vehicles` -0.25615 0.05393 -4.75 2.59e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.199 on 566 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.03833, Adjusted R-squared: 0.03663
## F-statistic: 22.56 on 1 and 566 DF, p-value: 2.587e-06
# compare to pre shelter in place
sj_no_vehicles_by_block %>%
ggplot(aes(
x = `percent with vehicles`,
y = `% not completely at home pre shelter`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of housholds with vehicles available",
y = "Percent devices leaving home on weekdays pre shelter-in-place",
title = "San Jose: Social Distancing and Vehicle Availability Pre Shelter-in-Place"
)
vehicles_model2 <- lm(`% not completely at home pre shelter` ~ `percent with vehicles`, sj_no_vehicles_by_block)
summary(vehicles_model2)
##
## Call:
## lm(formula = `% not completely at home pre shelter` ~ `percent with vehicles`,
## data = sj_no_vehicles_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -25.5618 -2.9606 -0.0694 3.0006 12.6053
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 63.25942 2.83717 22.297 < 2e-16 ***
## `percent with vehicles` 0.15084 0.02975 5.071 5.37e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.522 on 566 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.04346, Adjusted R-squared: 0.04177
## F-statistic: 25.72 on 1 and 566 DF, p-value: 5.37e-07
I also consider education and internet access, based on previous research. ## Education
sj_education_by_block <- getCensus(
name = "acs/acs5",
vintage = 2018,
region = "block group:*",
regionin = "state:06+county:085",
vars = "group(B15003)"
) %>%
mutate(
blockgroup =
paste0(state,county,tract,block_group)
) %>%
select_if(!names(.) %in% c("GEO_ID","state","county","tract","block_group","NAME")) %>%
select(-c(contains("EA"),contains("MA"),contains("M"))) %>%
gather(key = "variable", value = "estimate", -blockgroup) %>%
mutate(label = acs_vars$label[match(variable,acs_vars$name)]) %>%
select(-variable) %>%
separate(label, into = c(NA, NA, "education level"), sep = "!!") %>%
mutate(`education level` = replace_na(`education level`, "total_educ")) %>% # if the education level field is NA, this corresponded to the total number in that blockgroup
spread(key = `education level`, value = estimate) %>%
mutate(`percent associates or higher` = (`Associate's degree` + `Bachelor's degree` + `Doctorate degree` + `Master's degree`)*100/total_educ, `percent less than associates` = 100-`percent associates or higher`) %>%
left_join(sj_age_by_block %>% dplyr::select_if(!names(.) %in% c("elderly", "percent elderly", "less than 30", "percent less than 30"))) %>%
filter(!is.na(device_count))
# plotting
sj_education_by_block %>%
ggplot(aes(
x = `percent associates or higher`,
y = `% not completely at home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of people with an degree at Associate's level or higher",
y = "Percent devices leaving home on weekdays since shelter-in-place",
title = "San Jose: Social Distancing and Education"
)
educ_model <- lm(`% not completely at home` ~ `percent associates or higher`, sj_education_by_block)
summary(educ_model)
##
## Call:
## lm(formula = `% not completely at home` ~ `percent associates or higher`,
## data = sj_education_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -23.619 -4.747 -0.950 3.300 43.002
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 60.4003 0.8408 71.84 <2e-16 ***
## `percent associates or higher` -0.1910 0.0165 -11.58 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.606 on 567 degrees of freedom
## Multiple R-squared: 0.1912, Adjusted R-squared: 0.1898
## F-statistic: 134.1 on 1 and 567 DF, p-value: < 2.2e-16
# compare to pre shelter in place
sj_education_by_block %>%
ggplot(aes(
x = `percent associates or higher`,
y = `% not completely at home pre shelter`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of people with an degree at Associate's level or higher",
y = "Percent devices leaving home on weekdays pre-shelter-in-place",
title = "San Jose: Social Distancing and Education Pre Shelter-in-Place"
)
educ_model2 <- lm(`% not completely at home pre shelter` ~ `percent associates or higher`, sj_education_by_block)
summary(educ_model2)
##
## Call:
## lm(formula = `% not completely at home pre shelter` ~ `percent associates or higher`,
## data = sj_education_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -30.2224 -2.5458 0.0672 2.7859 13.9180
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 73.547853 0.476189 154.45 <2e-16 ***
## `percent associates or higher` 0.086343 0.009344 9.24 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.308 on 567 degrees of freedom
## Multiple R-squared: 0.1309, Adjusted R-squared: 0.1293
## F-statistic: 85.39 on 1 and 567 DF, p-value: < 2.2e-16
sj_internet_by_block <- getCensus(
name = "acs/acs5",
vintage = 2018,
region = "block group:*",
regionin = "state:06+county:085",
vars = "group(B28002)"
) %>%
mutate(
blockgroup =
paste0(state,county,tract,block_group)
) %>%
select_if(!names(.) %in% c("GEO_ID","state","county","tract","block_group","NAME")) %>%
select(-c(contains("EA"),contains("MA"),contains("M"))) %>%
gather(key = "variable", value = "estimate", -blockgroup) %>%
mutate(label = acs_vars$label[match(variable,acs_vars$name)]) %>%
select(-variable) %>%
separate(label, into = c(NA, NA, "subscription", "type", "additional"), sep = "!!") %>%
filter(is.na(subscription) | (type == "Broadband such as cable, fiber optic or DSL") & is.na(additional)) %>%
mutate(type = replace_na(type, "total_num")) %>%
dplyr::select(blockgroup, type, estimate) %>%
spread(key = type, value = estimate) %>%
mutate(`percent high speed` = `Broadband such as cable, fiber optic or DSL`*100/total_num, `percent no high speed` = 100-`percent high speed`) %>%
left_join(sj_age_by_block %>% dplyr::select_if(!names(.) %in% c("elderly", "percent elderly", "less than 30", "percent less than 30"))) %>%
filter(!is.na(device_count))
# plotting
sj_internet_by_block %>%
ggplot(aes(
x = `percent high speed`,
y = `% not completely at home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of households with broadband such as cable, fiber optic or DSL",
y = "Percent devices leaving home on weekdays since shelter-in-place",
title = "San Jose: Social Distancing and High Speed Internet"
)
internet_model <- lm(`% not completely at home` ~ `percent high speed`, sj_internet_by_block)
summary(internet_model)
##
## Call:
## lm(formula = `% not completely at home` ~ `percent high speed`,
## data = sj_internet_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -21.884 -4.676 -0.549 3.996 38.086
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 72.72612 2.22683 32.659 <2e-16 ***
## `percent high speed` -0.26512 0.02731 -9.709 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.741 on 566 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.1428, Adjusted R-squared: 0.1413
## F-statistic: 94.26 on 1 and 566 DF, p-value: < 2.2e-16
# compare to pre-shelter-in-place behavior
sj_internet_by_block %>%
ggplot(aes(
x = `percent high speed`,
y = `% not completely at home pre shelter`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of households with broadband such as cable, fiber optic or DSL",
y = "Percent devices leaving home on weekdays pre-shelter-in-place",
title = "San Jose: Social Distancing and High Speed Internet Pre Shelter-in-Place"
)
internet_model2 <- lm(`% not completely at home pre shelter` ~ `percent high speed`, sj_internet_by_block)
summary(internet_model2)
##
## Call:
## lm(formula = `% not completely at home pre shelter` ~ `percent high speed`,
## data = sj_internet_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -28.5915 -2.8440 -0.1157 2.8288 16.8750
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 69.1067 1.2800 53.990 < 2e-16 ***
## `percent high speed` 0.1055 0.0157 6.719 4.48e-11 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.449 on 566 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.07386, Adjusted R-squared: 0.07223
## F-statistic: 45.14 on 1 and 566 DF, p-value: 4.477e-11
# use LODES data
sj_sex_workers_by_block <- grab_lodes(
state = "ca",
year = 2017,
lodes_type = "rac",
job_type = "JT01",
segment = "S000",
state_part = "main",
agg_geo = "bg"
) %>%
left_join(sj_blockgroups, by = c("h_bg" = "GEOID")) %>%
filter(!is.na(DISTRICTS)) %>%
dplyr::select(CS01, CS02, h_bg) %>%
rename(male = CS01, female = CS02, blockgroup = h_bg) %>%
mutate(total_workers = male + female, `% male workers` = male*100 / total_workers) %>%
left_join(sj_age_by_block %>% dplyr::select_if(!names(.) %in% c("elderly", "percent elderly", "less than 30", "percent less than 30"))) %>%
filter(!is.na(device_count))
# plotting
sj_sex_workers_by_block %>%
ggplot(aes(
x = `% male workers`,
y = `% not completely at home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of workers that are male",
y = "Percent devices leaving home on weekdays since shelter-in-place",
title = "San Jose: Social Distancing and Sex of Workers"
)
sex_workers_model <- lm(`% not completely at home` ~ `% male workers`, sj_sex_workers_by_block)
summary(sex_workers_model)
##
## Call:
## lm(formula = `% not completely at home` ~ `% male workers`, data = sj_sex_workers_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -25.516 -5.392 -0.510 4.469 36.365
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 67.2451 7.1783 9.368 <2e-16 ***
## `% male workers` -0.2951 0.1338 -2.206 0.0278 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.388 on 566 degrees of freedom
## Multiple R-squared: 0.008526, Adjusted R-squared: 0.006774
## F-statistic: 4.867 on 1 and 566 DF, p-value: 0.02777
# compare to pre-shelter-in-place behavior
sj_sex_workers_by_block %>%
ggplot(aes(
x = `% male workers`,
y = `% not completely at home pre shelter`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of workers that are male",
y = "Percent devices leaving home on weekdays pre-shelter-in-place",
title = "San Jose: Social Distancing and Sex of Workers Pre Shelter-in-Place"
)
sex_workers_model_2 <- lm(`% not completely at home pre shelter` ~ `% male workers`, sj_sex_workers_by_block)
summary(sex_workers_model_2)
##
## Call:
## lm(formula = `% not completely at home pre shelter` ~ `% male workers`,
## data = sj_sex_workers_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -27.5200 -3.1184 -0.1399 3.0954 12.4701
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 78.61111 3.95446 19.879 <2e-16 ***
## `% male workers` -0.01836 0.07369 -0.249 0.803
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.621 on 566 degrees of freedom
## Multiple R-squared: 0.0001096, Adjusted R-squared: -0.001657
## F-statistic: 0.06207 on 1 and 566 DF, p-value: 0.8033
This does not seem to be significant.
sj_race_by_block <- getCensus(
name = "acs/acs5",
vintage = 2018,
region = "block group:*",
regionin = "state:06+county:085",
vars = "group(B02001)"
) %>%
mutate(
blockgroup =
paste0(state,county,tract,block_group)
) %>%
select_if(!names(.) %in% c("GEO_ID","state","county","tract","block_group","NAME")) %>%
select(-c(contains("EA"),contains("MA"),contains("M"))) %>%
gather(key = "variable", value = "estimate", -blockgroup) %>%
mutate(label = acs_vars$label[match(variable,acs_vars$name)]) %>%
select(-variable) %>%
separate(label, into = c(NA, NA, "race", "specification"), sep = "!!") %>%
filter(is.na(specification) & !is.na(race)) %>%
dplyr::select(blockgroup, estimate, race) %>%
spread(key = race, value = estimate) %>%
mutate(total_race = `American Indian and Alaska Native alone` + `Asian alone` + `Black or African American alone` + `Native Hawaiian and Other Pacific Islander alone` + `Some other race alone` + `Two or more races` + `White alone`, `% white` = `White alone`*100/total_race, `% Asian` = `Asian alone`*100/total_race, `% black` = `Black or African American alone`*100/total_race) %>%
left_join(sj_age_by_block %>% dplyr::select_if(!names(.) %in% c("elderly", "percent elderly", "less than 30", "percent less than 30"))) %>%
filter(!is.na(device_count))
# also get ethnicity data (hispanic/latino vs not)
sj_hisplat_by_block <- getCensus(
name = "acs/acs5",
vintage = 2018,
region = "block group:*",
regionin = "state:06+county:085",
vars = "group(B03002)"
) %>%
mutate(
blockgroup =
paste0(state,county,tract,block_group)
) %>%
select_if(!names(.) %in% c("GEO_ID","state","county","tract","block_group","NAME")) %>%
select(-c(contains("EA"),contains("MA"),contains("M"))) %>%
gather(key = "variable", value = "estimate", -blockgroup) %>%
mutate(label = acs_vars$label[match(variable,acs_vars$name)]) %>%
select(-variable) %>%
separate(label, into = c(NA, NA, "hisp/lat", "specification"), sep = "!!") %>%
filter(is.na(specification) & !is.na(`hisp/lat`)) %>%
dplyr::select(blockgroup, estimate, `hisp/lat`) %>%
spread(key = `hisp/lat`, value = estimate) %>%
mutate(`% non hispanic/latino` = `Not Hispanic or Latino`*100/(`Hispanic or Latino` + `Not Hispanic or Latino`))
# join with the race data
sj_race_by_block <- sj_race_by_block %>% left_join(sj_hisplat_by_block %>% dplyr::select(blockgroup, `% non hispanic/latino`))
# plotting
# percent white
sj_race_by_block %>%
ggplot(aes(
x = `% white`,
y = `% not completely at home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of residents that are white",
y = "Percent devices leaving home on weekdays since shelter-in-place",
title = "San Jose: Social Distancing and White Residents"
)
white_model <- lm(`% not completely at home` ~ `% white`, sj_race_by_block)
summary(white_model)
##
## Call:
## lm(formula = `% not completely at home` ~ `% white`, data = sj_race_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -25.625 -5.270 -0.390 4.665 37.436
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 50.12965 0.78574 63.8 <2e-16 ***
## `% white` 0.02933 0.01630 1.8 0.0724 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.434 on 567 degrees of freedom
## Multiple R-squared: 0.005681, Adjusted R-squared: 0.003927
## F-statistic: 3.24 on 1 and 567 DF, p-value: 0.07241
# compare to pre-shelter-in-place behavior
sj_race_by_block %>%
ggplot(aes(
x = `% white`,
y = `% not completely at home pre shelter`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of residents that are white",
y = "Percent devices leaving home on weekdays pre-shelter-in-place",
title = "San Jose: Social Distancing and White Residents Pre Shelter-in-Place"
)
white_model2 <- lm(`% not completely at home pre shelter` ~ `% white`, sj_race_by_block)
summary(white_model2)
##
## Call:
## lm(formula = `% not completely at home pre shelter` ~ `% white`,
## data = sj_race_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -28.2995 -2.8302 -0.0347 2.8574 12.5621
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 74.834803 0.410114 182.473 < 2e-16 ***
## `% white` 0.064673 0.008506 7.603 1.21e-13 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.402 on 567 degrees of freedom
## Multiple R-squared: 0.09251, Adjusted R-squared: 0.09091
## F-statistic: 57.8 on 1 and 567 DF, p-value: 1.209e-13
# percent Asian
sj_race_by_block %>%
ggplot(aes(
x = `% Asian`,
y = `% not completely at home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of residents that are Asian",
y = "Percent devices leaving home on weekdays since shelter-in-place",
title = "San Jose: Social Distancing and Asian Residents"
)
asian_model <- lm(`% not completely at home` ~ `% Asian`, sj_race_by_block)
summary(asian_model)
##
## Call:
## lm(formula = `% not completely at home` ~ `% Asian`, data = sj_race_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -21.032 -5.012 -0.564 4.386 36.002
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 56.20411 0.59228 94.894 <2e-16 ***
## `% Asian` -0.14825 0.01519 -9.757 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.826 on 567 degrees of freedom
## Multiple R-squared: 0.1438, Adjusted R-squared: 0.1423
## F-statistic: 95.21 on 1 and 567 DF, p-value: < 2.2e-16
# compare to pre-shelter-in-place behavior
sj_race_by_block %>%
ggplot(aes(
x = `% Asian`,
y = `% not completely at home pre shelter`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of residents that are Asian",
y = "Percent devices leaving home on weekdays pre-shelter-in-place",
title = "San Jose: Social Distancing and Asian Residents Pre Shelter-in-Place"
)
asian_model2 <- lm(`% not completely at home pre shelter` ~ `% Asian`, sj_race_by_block)
summary(asian_model2)
##
## Call:
## lm(formula = `% not completely at home pre shelter` ~ `% Asian`,
## data = sj_race_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -27.6447 -3.0068 0.0283 3.2005 12.1305
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 78.069520 0.348967 223.72 <2e-16 ***
## `% Asian` -0.013871 0.008952 -1.55 0.122
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.611 on 567 degrees of freedom
## Multiple R-squared: 0.004217, Adjusted R-squared: 0.00246
## F-statistic: 2.401 on 1 and 567 DF, p-value: 0.1218
# percent non hispanic/latino
sj_race_by_block %>%
ggplot(aes(
x = `% non hispanic/latino`,
y = `% not completely at home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of residents that are not Hispanic or Latino",
y = "Percent devices leaving home on weekdays since shelter-in-place",
title = "San Jose: Social Distancing and Hispanic/Latino Residents"
)
hisp_model <- lm(`% not completely at home` ~ `% non hispanic/latino`, sj_race_by_block)
summary(hisp_model)
##
## Call:
## lm(formula = `% not completely at home` ~ `% non hispanic/latino`,
## data = sj_race_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -23.581 -4.752 -0.802 3.749 37.993
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 62.21783 1.02147 60.91 <2e-16 ***
## `% non hispanic/latino` -0.15911 0.01425 -11.16 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.658 on 567 degrees of freedom
## Multiple R-squared: 0.1802, Adjusted R-squared: 0.1787
## F-statistic: 124.6 on 1 and 567 DF, p-value: < 2.2e-16
# compare to pre-shelter-in-place behavior
sj_race_by_block %>%
ggplot(aes(
x = `% non hispanic/latino`,
y = `% not completely at home pre shelter`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of residents that are not Hispanic or Latino",
y = "Percent devices leaving home on weekdays pre-shelter-in-place",
title = "San Jose: Social Distancing and Hispanic/Latino Residents Pre Shelter-in-Place"
)
hisp_model2 <- lm(`% not completely at home pre shelter` ~ `% non hispanic/latino`, sj_race_by_block)
summary(hisp_model2)
##
## Call:
## lm(formula = `% not completely at home pre shelter` ~ `% non hispanic/latino`,
## data = sj_race_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -28.6826 -2.6760 -0.0257 3.0167 16.7253
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 73.005160 0.581580 125.529 < 2e-16 ***
## `% non hispanic/latino` 0.067819 0.008115 8.357 4.97e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 4.36 on 567 degrees of freedom
## Multiple R-squared: 0.1097, Adjusted R-squared: 0.1081
## F-statistic: 69.85 on 1 and 567 DF, p-value: 4.967e-16
# multiple regression
modeltest <- lm(sj_ami_by_block$`% not completely at home` ~ sj_ami_by_block$`% over 125,000` + sj_age_by_block$`percent less than 30` + sj_lang_by_block$`% speaking english > well` + sj_occupants_per_room_by_block$`percent less than 1`)
summary(modeltest)
##
## Call:
## lm(formula = sj_ami_by_block$`% not completely at home` ~ sj_ami_by_block$`% over 125,000` +
## sj_age_by_block$`percent less than 30` + sj_lang_by_block$`% speaking english > well` +
## sj_occupants_per_room_by_block$`percent less than 1`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -23.490 -4.658 -0.797 3.973 32.270
##
## Coefficients:
## Estimate Std. Error
## (Intercept) 50.72548 4.77236
## sj_ami_by_block$`% over 125,000` -0.23965 0.02152
## sj_age_by_block$`percent less than 30` 0.01581 0.04209
## sj_lang_by_block$`% speaking english > well` 0.13432 0.04611
## sj_occupants_per_room_by_block$`percent less than 1` -0.02274 0.04614
## t value Pr(>|t|)
## (Intercept) 10.629 < 2e-16 ***
## sj_ami_by_block$`% over 125,000` -11.135 < 2e-16 ***
## sj_age_by_block$`percent less than 30` 0.376 0.70739
## sj_lang_by_block$`% speaking english > well` 2.913 0.00372 **
## sj_occupants_per_room_by_block$`percent less than 1` -0.493 0.62234
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.297 on 563 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.2423, Adjusted R-squared: 0.2369
## F-statistic: 45 on 4 and 563 DF, p-value: < 2.2e-16
educ_income_model <- lm(sj_ami_by_block$`% not completely at home` ~ sj_ami_by_block$`% over 125,000` + sj_education_by_block$`percent associates or higher`)
summary(educ_income_model)
##
## Call:
## lm(formula = sj_ami_by_block$`% not completely at home` ~ sj_ami_by_block$`% over 125,000` +
## sj_education_by_block$`percent associates or higher`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -22.731 -4.702 -1.052 3.700 32.133
##
## Coefficients:
## Estimate Std. Error
## (Intercept) 61.47695 0.82679
## sj_ami_by_block$`% over 125,000` -0.15122 0.02258
## sj_education_by_block$`percent associates or higher` -0.08302 0.02219
## t value Pr(>|t|)
## (Intercept) 74.356 < 2e-16 ***
## sj_ami_by_block$`% over 125,000` -6.697 5.15e-11 ***
## sj_education_by_block$`percent associates or higher` -3.741 0.000202 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.257 on 565 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.248, Adjusted R-squared: 0.2454
## F-statistic: 93.18 on 2 and 565 DF, p-value: < 2.2e-16
educ_income_model <- lm(sj_ami_by_block$`% not completely at home` ~ sj_ami_by_block$`% over 125,000` + sj_internet_by_block$`percent high speed`)
summary(educ_income_model)
##
## Call:
## lm(formula = sj_ami_by_block$`% not completely at home` ~ sj_ami_by_block$`% over 125,000` +
## sj_internet_by_block$`percent high speed`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -22.166 -4.531 -0.761 4.120 32.120
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 65.16907 2.28887 28.472 < 2e-16
## sj_ami_by_block$`% over 125,000` -0.17772 0.02127 -8.356 5.03e-16
## sj_internet_by_block$`percent high speed` -0.08082 0.03393 -2.382 0.0175
##
## (Intercept) ***
## sj_ami_by_block$`% over 125,000` ***
## sj_internet_by_block$`percent high speed` *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.309 on 565 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.2371, Adjusted R-squared: 0.2344
## F-statistic: 87.78 on 2 and 565 DF, p-value: < 2.2e-16
income_spanish_model <- lm(sj_ami_by_block$`% not completely at home` ~ sj_ami_by_block$`% over 125,000` + sj_lang_by_block$`% not speaking spanish`)
summary(income_spanish_model)
##
## Call:
## lm(formula = sj_ami_by_block$`% not completely at home` ~ sj_ami_by_block$`% over 125,000` +
## sj_lang_by_block$`% not speaking spanish`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -23.210 -4.657 -0.882 3.991 32.085
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 62.48255 1.23594 50.555 <2e-16
## sj_ami_by_block$`% over 125,000` -0.17861 0.02066 -8.647 <2e-16
## sj_lang_by_block$`% not speaking spanish` -0.04882 0.01961 -2.489 0.0131
##
## (Intercept) ***
## sj_ami_by_block$`% over 125,000` ***
## sj_lang_by_block$`% not speaking spanish` *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.306 on 565 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.2378, Adjusted R-squared: 0.2351
## F-statistic: 88.12 on 2 and 565 DF, p-value: < 2.2e-16
This suggests that once controlling for income, Spanish language ability is no longer a strong predictor of leaving home during the shelter-in-place order.
Now I consider looking at correlations with the change in percent of devices staying completely at home since shelter-in-place started relative to the pre-shelter-in-place levels. I plot the change in percentage staying completely at home, and show linear fitting models for the change in percent staying at home, as well as the fractional increase in percent staying home.
# collect the demographic variables
sj_dem_distancing <- sj_internet_by_block %>%
dplyr::select(`percent high speed`, `% not completely at home`, `% Completely at Home`, blockgroup) %>%
left_join(sj_education_by_block %>% dplyr::select(blockgroup, `percent associates or higher`)) %>%
left_join(sj_ami_by_block %>% dplyr::select(blockgroup, `% over 125,000`)) %>%
left_join(sj_ami_by_block %>% dplyr::select(blockgroup, `% over 100,000`)) %>%
left_join(sj_ami_by_block %>% dplyr::select(blockgroup, `% over 75,000`)) %>%
left_join(sj_age_by_block %>% dplyr::select(blockgroup, `percent less than 30`)) %>%
left_join(sj_age_by_block %>% dplyr::select(blockgroup, `percent elderly`)) %>%
left_join(sj_lang_by_block %>% dplyr::select(blockgroup, `% not speaking spanish`)) %>%
left_join(sj_lang_by_block %>% dplyr::select(blockgroup, `% speaking english > well`)) %>%
left_join(sj_no_vehicles_by_block %>% dplyr::select(blockgroup, `percent with vehicles`)) %>%
left_join(sj_occupants_per_room_by_block %>% dplyr::select(blockgroup, `percent less than 1`)) %>%
left_join(sj_sex_workers_by_block %>% dplyr::select(blockgroup, `% male workers`)) %>%
left_join(sj_race_by_block %>% dplyr::select(blockgroup, `% white`, `% Asian`, `% non hispanic/latino`))
sj_dem_distancing_pre_post <- sj_dem_distancing %>%
left_join(sj_internet_by_block %>% dplyr::select(`% not completely at home pre shelter`, `% Completely at Home Pre Shelter`, blockgroup)) %>%
mutate(`% increase in staying completely home` = `% Completely at Home` - `% Completely at Home Pre Shelter`, frac_increase = `% increase in staying completely home`/`% Completely at Home Pre Shelter`)
sj_dem_distancing[is.na(sj_dem_distancing)] <- 0
sj_dem_distancing_pre_post[is.na(sj_dem_distancing_pre_post)] <- 0
saveRDS(sj_dem_distancing_pre_post, "/Users/simonespeizer/Documents/2020 Spring Quarter/CEE 218Z/covid19/Simone_Speizer/sj_socialdistancing_demdata_prepostdifs_manyvars.rds")
# sj_dem_distancing_pre_post <- readRDS("/Users/simonespeizer/Documents/2020 Spring Quarter/CEE 218Z/covid19/Simone_Speizer/sj_socialdistancing_demdata_prepostdifs_manyvars.rds")
# age
sj_dem_distancing_pre_post %>%
ggplot(aes(
x = `percent less than 30`,
y = `% increase in staying completely home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of residents younger than 30",
y = "Dif in % completely at home after shelter-in-place relative to before",
title = "San Jose: Social Distancing and Young Age Groups"
)
young_model_dif <- lm(sj_dem_distancing_pre_post$`% increase in staying completely home` ~ sj_dem_distancing_pre_post$`percent less than 30`)
summary(young_model_dif)
##
## Call:
## lm(formula = sj_dem_distancing_pre_post$`% increase in staying completely home` ~
## sj_dem_distancing_pre_post$`percent less than 30`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -38.099 -5.332 -0.019 5.441 30.340
##
## Coefficients:
## Estimate Std. Error t value
## (Intercept) 37.37809 1.73272 21.572
## sj_dem_distancing_pre_post$`percent less than 30` -0.29045 0.04392 -6.613
## Pr(>|t|)
## (Intercept) < 2e-16 ***
## sj_dem_distancing_pre_post$`percent less than 30` 8.72e-11 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 9.501 on 567 degrees of freedom
## Multiple R-squared: 0.0716, Adjusted R-squared: 0.06997
## F-statistic: 43.73 on 1 and 567 DF, p-value: 8.723e-11
young_model_frac <- lm(sj_dem_distancing_pre_post$frac_increase ~ sj_dem_distancing_pre_post$`percent less than 30`)
summary(young_model_frac)
##
## Call:
## lm(formula = sj_dem_distancing_pre_post$frac_increase ~ sj_dem_distancing_pre_post$`percent less than 30`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.06950 -0.38930 -0.09973 0.31118 2.99148
##
## Coefficients:
## Estimate Std. Error t value
## (Intercept) 2.109231 0.119117 17.707
## sj_dem_distancing_pre_post$`percent less than 30` -0.021700 0.003019 -7.187
## Pr(>|t|)
## (Intercept) < 2e-16 ***
## sj_dem_distancing_pre_post$`percent less than 30` 2.1e-12 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.6531 on 567 degrees of freedom
## Multiple R-squared: 0.08349, Adjusted R-squared: 0.08187
## F-statistic: 51.65 on 1 and 567 DF, p-value: 2.102e-12
sj_dem_distancing_pre_post %>% filter(`percent elderly` < 50) %>% # get rid of extreme outliers
ggplot(aes(
x = `percent elderly`,
y = `% increase in staying completely home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of residents 65 and older",
y = "Dif in % completely at home after shelter-in-place relative to before",
title = "San Jose: Social Distancing and Elderly Population"
)
elderly_model_dif <- lm(`% increase in staying completely home` ~ `percent elderly`, sj_dem_distancing_pre_post %>% filter(`percent elderly` < 50))
summary(elderly_model_dif)
##
## Call:
## lm(formula = `% increase in staying completely home` ~ `percent elderly`,
## data = sj_dem_distancing_pre_post %>% filter(`percent elderly` <
## 50))
##
## Residuals:
## Min 1Q Median 3Q Max
## -40.371 -5.656 -0.321 6.062 31.123
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 22.25429 0.90241 24.661 < 2e-16 ***
## `percent elderly` 0.31026 0.06231 4.979 8.49e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 9.636 on 564 degrees of freedom
## Multiple R-squared: 0.04211, Adjusted R-squared: 0.04041
## F-statistic: 24.79 on 1 and 564 DF, p-value: 8.494e-07
elderly_model_frac <- lm(frac_increase ~ `percent elderly`, sj_dem_distancing_pre_post %>% filter(`percent elderly` < 50))
summary(elderly_model_frac)
##
## Call:
## lm(formula = frac_increase ~ `percent elderly`, data = sj_dem_distancing_pre_post %>%
## filter(`percent elderly` < 50))
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.66307 -0.41921 -0.09938 0.33958 3.03923
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.952358 0.062041 15.350 < 2e-16 ***
## `percent elderly` 0.025211 0.004284 5.885 6.83e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.6625 on 564 degrees of freedom
## Multiple R-squared: 0.05786, Adjusted R-squared: 0.05618
## F-statistic: 34.63 on 1 and 564 DF, p-value: 6.83e-09
# income - less than $75000
sj_dem_distancing_pre_post %>%
ggplot(aes(
x = `% over 75,000`,
y = `% increase in staying completely home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of housholds with incomes over $75,000 (50% AMI) annually",
y = "Dif in % completely at home after shelter-in-place relative to before",
title = "San Jose: Social Distancing and Households Above 50% AMI"
)
income_75_model_dif <- lm(`% increase in staying completely home` ~ `% over 75,000`, sj_dem_distancing_pre_post)
summary(income_75_model_dif)
##
## Call:
## lm(formula = `% increase in staying completely home` ~ `% over 75,000`,
## data = sj_dem_distancing_pre_post)
##
## Residuals:
## Min 1Q Median 3Q Max
## -36.384 -4.457 0.583 4.887 24.116
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8.01692 1.22405 6.55 1.3e-10 ***
## `% over 75,000` 0.29290 0.01888 15.51 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.262 on 567 degrees of freedom
## Multiple R-squared: 0.2979, Adjusted R-squared: 0.2967
## F-statistic: 240.6 on 1 and 567 DF, p-value: < 2.2e-16
income_75_model_frac <- lm(frac_increase ~ `% over 75,000`, sj_dem_distancing_pre_post)
summary(income_75_model_frac)
##
## Call:
## lm(formula = frac_increase ~ `% over 75,000`, data = sj_dem_distancing_pre_post)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.83204 -0.32033 -0.04946 0.27833 2.50717
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.052042 0.085694 0.607 0.544
## `% over 75,000` 0.019689 0.001322 14.893 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5784 on 567 degrees of freedom
## Multiple R-squared: 0.2812, Adjusted R-squared: 0.2799
## F-statistic: 221.8 on 1 and 567 DF, p-value: < 2.2e-16
# income - less than $100000
sj_dem_distancing_pre_post %>%
ggplot(aes(
x = `% over 100,000`,
y = `% increase in staying completely home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of housholds with incomes over $100,000 (80% AMI) annually",
y = "Dif in % completely at home after shelter-in-place relative to before",
title = "San Jose: Social Distancing and Households Below 80% AMI"
)
income_100_model_dif <- lm(`% increase in staying completely home` ~ `% over 100,000`, sj_dem_distancing_pre_post)
summary(income_100_model_dif)
##
## Call:
## lm(formula = `% increase in staying completely home` ~ `% over 100,000`,
## data = sj_dem_distancing_pre_post)
##
## Residuals:
## Min 1Q Median 3Q Max
## -36.374 -4.444 0.903 5.291 20.808
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 11.28215 0.94618 11.92 <2e-16 ***
## `% over 100,000` 0.29341 0.01736 16.90 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.04 on 567 degrees of freedom
## Multiple R-squared: 0.3351, Adjusted R-squared: 0.3339
## F-statistic: 285.7 on 1 and 567 DF, p-value: < 2.2e-16
income_100_model_frac <- lm(frac_increase ~ `% over 100,000`, sj_dem_distancing_pre_post)
summary(income_100_model_frac)
##
## Call:
## lm(formula = frac_increase ~ `% over 100,000`, data = sj_dem_distancing_pre_post)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.93189 -0.32427 -0.01608 0.27844 2.59102
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.248903 0.065682 3.79 0.000167 ***
## `% over 100,000` 0.020167 0.001205 16.74 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5581 on 567 degrees of freedom
## Multiple R-squared: 0.3307, Adjusted R-squared: 0.3295
## F-statistic: 280.1 on 1 and 567 DF, p-value: < 2.2e-16
# income - less than $125000
sj_dem_distancing_pre_post %>%
ggplot(aes(
x = `% over 125,000`,
y = `% increase in staying completely home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of housholds with incomes over $125,000 annually",
y = "Dif in % completely at home after shelter-in-place relative to before",
title = "San Jose: Social Distancing and Households Below $125,000"
)
income_125_model_dif <- lm(`% increase in staying completely home` ~ `% over 125,000`, sj_dem_distancing_pre_post)
summary(income_125_model_dif)
##
## Call:
## lm(formula = `% increase in staying completely home` ~ `% over 125,000`,
## data = sj_dem_distancing_pre_post)
##
## Residuals:
## Min 1Q Median 3Q Max
## -37.223 -4.149 0.709 5.144 21.349
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 13.47554 0.78589 17.15 <2e-16 ***
## `% over 125,000` 0.31049 0.01736 17.88 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.884 on 567 degrees of freedom
## Multiple R-squared: 0.3606, Adjusted R-squared: 0.3595
## F-statistic: 319.8 on 1 and 567 DF, p-value: < 2.2e-16
income_125_model_frac <- lm(frac_increase ~ `% over 125,000`, sj_dem_distancing_pre_post)
summary(income_125_model_frac)
##
## Call:
## lm(formula = frac_increase ~ `% over 125,000`, data = sj_dem_distancing_pre_post)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.01139 -0.30318 0.00149 0.27402 2.47074
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.372176 0.053608 6.943 1.06e-11 ***
## `% over 125,000` 0.022011 0.001184 18.586 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5378 on 567 degrees of freedom
## Multiple R-squared: 0.3786, Adjusted R-squared: 0.3775
## F-statistic: 345.4 on 1 and 567 DF, p-value: < 2.2e-16
# language
sj_dem_distancing_pre_post %>%
ggplot(aes(
x = `% speaking english > well`,
y = `% increase in staying completely home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of individuals speaking English well",
y = "Dif in % completely at home after shelter-in-place relative to before",
title = "San Jose: Social Distancing and English Language Ability"
)
english_ability_model_dif <- lm(`% increase in staying completely home` ~ `% speaking english > well`, sj_dem_distancing_pre_post)
summary(english_ability_model_dif)
##
## Call:
## lm(formula = `% increase in staying completely home` ~ `% speaking english > well`,
## data = sj_dem_distancing_pre_post)
##
## Residuals:
## Min 1Q Median 3Q Max
## -36.714 -4.743 0.360 5.067 29.631
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -6.44360 3.75014 -1.718 0.0863 .
## `% speaking english > well` 0.36828 0.04205 8.759 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 9.254 on 567 degrees of freedom
## Multiple R-squared: 0.1192, Adjusted R-squared: 0.1176
## F-statistic: 76.72 on 1 and 567 DF, p-value: < 2.2e-16
english_ability_model_frac <- lm(frac_increase ~ `% speaking english > well`, sj_dem_distancing_pre_post)
summary(english_ability_model_frac)
##
## Call:
## lm(formula = frac_increase ~ `% speaking english > well`, data = sj_dem_distancing_pre_post)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.57800 -0.35263 -0.03443 0.28771 2.76709
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.408245 0.252168 -5.585 3.64e-08 ***
## `% speaking english > well` 0.030260 0.002827 10.702 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.6223 on 567 degrees of freedom
## Multiple R-squared: 0.1681, Adjusted R-squared: 0.1666
## F-statistic: 114.5 on 1 and 567 DF, p-value: < 2.2e-16
sj_dem_distancing_pre_post %>%
ggplot(aes(
x = `% not speaking spanish`,
y = `% increase in staying completely home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of individuals not speaking Spanish",
y = "Dif in % completely at home after shelter-in-place relative to before",
title = "San Jose: Social Distancing and Spanish Language Ability"
)
spanish_speaking_model_dif <- lm(`% increase in staying completely home` ~ `% not speaking spanish`, sj_dem_distancing_pre_post)
summary(spanish_speaking_model_dif)
##
## Call:
## lm(formula = `% increase in staying completely home` ~ `% not speaking spanish`,
## data = sj_dem_distancing_pre_post)
##
## Residuals:
## Min 1Q Median 3Q Max
## -40.698 -3.803 0.725 5.249 25.544
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 7.60830 1.45033 5.246 2.2e-07 ***
## `% not speaking spanish` 0.23948 0.01807 13.255 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.615 on 567 degrees of freedom
## Multiple R-squared: 0.2366, Adjusted R-squared: 0.2352
## F-statistic: 175.7 on 1 and 567 DF, p-value: < 2.2e-16
spanish_speaking_model_frac <- lm(frac_increase ~ `% not speaking spanish`, sj_dem_distancing_pre_post)
summary(spanish_speaking_model_frac)
##
## Call:
## lm(formula = frac_increase ~ `% not speaking spanish`, data = sj_dem_distancing_pre_post)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.70690 -0.34204 -0.02644 0.27032 2.59126
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.038591 0.099700 -0.387 0.699
## `% not speaking spanish` 0.016910 0.001242 13.615 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5922 on 567 degrees of freedom
## Multiple R-squared: 0.2464, Adjusted R-squared: 0.2451
## F-statistic: 185.4 on 1 and 567 DF, p-value: < 2.2e-16
# occupants per room
sj_dem_distancing_pre_post %>%
ggplot(aes(
x = `percent less than 1`,
y = `% increase in staying completely home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of households with 1 or fewer occupant per room",
y = "Dif in % completely at home after shelter-in-place relative to before",
title = "San Jose: Social Distancing and Room Occupancy"
)
occupants_model_dif <- lm(`% increase in staying completely home` ~ `percent less than 1`, sj_dem_distancing_pre_post)
summary(occupants_model_dif)
##
## Call:
## lm(formula = `% increase in staying completely home` ~ `percent less than 1`,
## data = sj_dem_distancing_pre_post)
##
## Residuals:
## Min 1Q Median 3Q Max
## -39.954 -4.933 0.441 5.152 27.198
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -7.01812 3.08531 -2.275 0.0233 *
## `percent less than 1` 0.36920 0.03401 10.856 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.972 on 567 degrees of freedom
## Multiple R-squared: 0.1721, Adjusted R-squared: 0.1706
## F-statistic: 117.9 on 1 and 567 DF, p-value: < 2.2e-16
occupants_model_frac <- lm(frac_increase ~ `percent less than 1`, sj_dem_distancing_pre_post)
summary(occupants_model_frac)
##
## Call:
## lm(formula = frac_increase ~ `percent less than 1`, data = sj_dem_distancing_pre_post)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.64839 -0.37296 -0.06277 0.27145 2.69847
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.158244 0.210792 -5.495 5.92e-08 ***
## `percent less than 1` 0.027035 0.002323 11.635 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.613 on 567 degrees of freedom
## Multiple R-squared: 0.1927, Adjusted R-squared: 0.1913
## F-statistic: 135.4 on 1 and 567 DF, p-value: < 2.2e-16
# vehicles - percent with no vehicles
sj_dem_distancing_pre_post %>%
ggplot(aes(
x = `percent with vehicles`,
y = `% increase in staying completely home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of housholds with vehicles available",
y = "Dif in % completely at home after shelter-in-place relative to before",
title = "San Jose: Social Distancing and Vehicle Availability"
)
vehicles_model_dif <- lm(`% increase in staying completely home` ~ `percent with vehicles`, sj_dem_distancing_pre_post)
summary(vehicles_model_dif)
##
## Call:
## lm(formula = `% increase in staying completely home` ~ `percent with vehicles`,
## data = sj_dem_distancing_pre_post)
##
## Residuals:
## Min 1Q Median 3Q Max
## -42.016 -5.916 0.106 5.629 29.764
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -9.67170 5.01754 -1.928 0.0544 .
## `percent with vehicles` 0.37787 0.05265 7.177 2.24e-12 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 9.441 on 567 degrees of freedom
## Multiple R-squared: 0.08328, Adjusted R-squared: 0.08166
## F-statistic: 51.51 on 1 and 567 DF, p-value: 2.244e-12
vehicles_model_frac <- lm(frac_increase ~ `percent with vehicles`, sj_dem_distancing_pre_post)
summary(vehicles_model_frac)
##
## Call:
## lm(formula = frac_increase ~ `percent with vehicles`, data = sj_dem_distancing_pre_post)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.8015 -0.4422 -0.1204 0.3100 2.8799
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.998778 0.349695 -2.856 0.00445 **
## `percent with vehicles` 0.023946 0.003669 6.526 1.5e-10 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.658 on 567 degrees of freedom
## Multiple R-squared: 0.06986, Adjusted R-squared: 0.06822
## F-statistic: 42.58 on 1 and 567 DF, p-value: 1.503e-10
sj_dem_distancing_pre_post %>%
ggplot(aes(
x = `percent associates or higher`,
y = `% increase in staying completely home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of people with an degree at Associate's level or higher",
y = "Dif in % completely at home after shelter-in-place relative to before",
title = "San Jose: Social Distancing and Education"
)
educ_model_dif <- lm(`% increase in staying completely home` ~ `percent associates or higher`, sj_dem_distancing_pre_post)
summary(educ_model_dif)
##
## Call:
## lm(formula = `% increase in staying completely home` ~ `percent associates or higher`,
## data = sj_dem_distancing_pre_post)
##
## Residuals:
## Min 1Q Median 3Q Max
## -40.284 -3.059 1.107 5.124 22.190
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 13.14752 0.91413 14.38 <2e-16 ***
## `percent associates or higher` 0.27737 0.01794 15.46 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.27 on 567 degrees of freedom
## Multiple R-squared: 0.2966, Adjusted R-squared: 0.2954
## F-statistic: 239.1 on 1 and 567 DF, p-value: < 2.2e-16
educ_model_frac <- lm(frac_increase ~ `percent associates or higher`, sj_dem_distancing_pre_post)
summary(educ_model_frac)
##
## Call:
## lm(formula = frac_increase ~ `percent associates or higher`,
## data = sj_dem_distancing_pre_post)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.26600 -0.31586 0.00808 0.28974 2.48982
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.357339 0.062837 5.687 2.07e-08 ***
## `percent associates or higher` 0.019484 0.001233 15.802 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5685 on 567 degrees of freedom
## Multiple R-squared: 0.3057, Adjusted R-squared: 0.3045
## F-statistic: 249.7 on 1 and 567 DF, p-value: < 2.2e-16
sj_dem_distancing_pre_post %>%
ggplot(aes(
x = `percent high speed`,
y = `% increase in staying completely home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of households with broadband such as cable, fiber optic or DSL",
y = "Dif in % completely at home after shelter-in-place relative to before",
title = "San Jose: Social Distancing and High Speed Internet"
)
internet_model_dif <- lm(`% increase in staying completely home` ~ `percent high speed`, sj_dem_distancing_pre_post)
summary(internet_model_dif)
##
## Call:
## lm(formula = `% increase in staying completely home` ~ `percent high speed`,
## data = sj_dem_distancing_pre_post)
##
## Residuals:
## Min 1Q Median 3Q Max
## -39.462 -4.781 0.411 5.399 26.685
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -3.54147 2.41478 -1.467 0.143
## `percent high speed` 0.36963 0.02964 12.472 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.735 on 567 degrees of freedom
## Multiple R-squared: 0.2153, Adjusted R-squared: 0.2139
## F-statistic: 155.5 on 1 and 567 DF, p-value: < 2.2e-16
internet_model_frac <- lm(frac_increase ~ `percent high speed`, sj_dem_distancing_pre_post)
summary(internet_model_frac)
##
## Call:
## lm(formula = frac_increase ~ `percent high speed`, data = sj_dem_distancing_pre_post)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.7085 -0.3548 -0.0774 0.2784 2.6841
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.677570 0.169360 -4.001 7.15e-05 ***
## `percent high speed` 0.024258 0.002079 11.671 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.6126 on 567 degrees of freedom
## Multiple R-squared: 0.1937, Adjusted R-squared: 0.1923
## F-statistic: 136.2 on 1 and 567 DF, p-value: < 2.2e-16
sj_dem_distancing_pre_post %>%
ggplot(aes(
x = `% male workers`,
y = `% increase in staying completely home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of workers that are male",
y = "Dif in % completely at home after shelter-in-place relative to before",
title = "San Jose: Social Distancing and Sex of Workers"
)
sex_workers_model_dif <- lm(`% increase in staying completely home` ~ `% male workers`, sj_dem_distancing_pre_post)
summary(sex_workers_model_dif)
##
## Call:
## lm(formula = `% increase in staying completely home` ~ `% male workers`,
## data = sj_dem_distancing_pre_post)
##
## Residuals:
## Min 1Q Median 3Q Max
## -42.390 -6.247 -0.230 6.165 30.825
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 24.14743 6.41049 3.767 0.000183 ***
## `% male workers` 0.03886 0.11956 0.325 0.745277
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 9.859 on 567 degrees of freedom
## Multiple R-squared: 0.0001863, Adjusted R-squared: -0.001577
## F-statistic: 0.1056 on 1 and 567 DF, p-value: 0.7453
sex_workers_model_frac <- lm(frac_increase ~ `% male workers`, sj_dem_distancing_pre_post)
summary(sex_workers_model_frac)
##
## Call:
## lm(formula = frac_increase ~ `% male workers`, data = sj_dem_distancing_pre_post)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.8587 -0.4506 -0.1051 0.3343 2.8996
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.715952 0.442955 1.616 0.107
## `% male workers` 0.010469 0.008261 1.267 0.206
##
## Residual standard error: 0.6813 on 567 degrees of freedom
## Multiple R-squared: 0.002824, Adjusted R-squared: 0.001065
## F-statistic: 1.606 on 1 and 567 DF, p-value: 0.2056
# white
sj_dem_distancing_pre_post %>%
ggplot(aes(
x = `% white`,
y = `% increase in staying completely home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of residents that are white",
y = "Dif in % completely at home after shelter-in-place relative to before",
title = "San Jose: Social Distancing and White Residents"
)
white_model_dif <- lm(`% increase in staying completely home` ~ `% white`, sj_dem_distancing_pre_post)
summary(white_model_dif)
##
## Call:
## lm(formula = `% increase in staying completely home` ~ `% white`,
## data = sj_dem_distancing_pre_post)
##
## Residuals:
## Min 1Q Median 3Q Max
## -42.164 -5.746 -0.222 6.115 31.833
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 24.70515 0.91587 26.98 <2e-16 ***
## `% white` 0.03534 0.01900 1.86 0.0634 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 9.83 on 567 degrees of freedom
## Multiple R-squared: 0.006066, Adjusted R-squared: 0.004314
## F-statistic: 3.461 on 1 and 567 DF, p-value: 0.06336
white_model_frac <- lm(frac_increase ~ `% white`, sj_dem_distancing_pre_post)
summary(white_model_frac)
##
## Call:
## lm(formula = frac_increase ~ `% white`, data = sj_dem_distancing_pre_post)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.8034 -0.4237 -0.0745 0.3101 2.9611
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.995999 0.062182 16.017 < 2e-16 ***
## `% white` 0.006506 0.001290 5.044 6.15e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.6674 on 567 degrees of freedom
## Multiple R-squared: 0.04294, Adjusted R-squared: 0.04126
## F-statistic: 25.44 on 1 and 567 DF, p-value: 6.146e-07
# asian
sj_dem_distancing_pre_post %>%
ggplot(aes(
x = `% Asian`,
y = `% increase in staying completely home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of residents that are Asian",
y = "Dif in % completely at home after shelter-in-place relative to before",
title = "San Jose: Social Distancing and Asian Residents"
)
asian_model_dif <- lm(`% increase in staying completely home` ~ `% Asian`, sj_dem_distancing_pre_post)
summary(asian_model_dif)
##
## Call:
## lm(formula = `% increase in staying completely home` ~ `% Asian`,
## data = sj_dem_distancing_pre_post)
##
## Residuals:
## Min 1Q Median 3Q Max
## -42.123 -5.662 -0.366 6.008 26.118
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 21.86541 0.71307 30.664 < 2e-16 ***
## `% Asian` 0.13438 0.01829 7.346 7.13e-13 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 9.422 on 567 degrees of freedom
## Multiple R-squared: 0.08691, Adjusted R-squared: 0.0853
## F-statistic: 53.97 on 1 and 567 DF, p-value: 7.132e-13
asian_model_frac <- lm(frac_increase ~ `% Asian`, sj_dem_distancing_pre_post)
summary(asian_model_frac)
##
## Call:
## lm(formula = frac_increase ~ `% Asian`, data = sj_dem_distancing_pre_post)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.8110 -0.4508 -0.1314 0.3053 2.9293
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.114130 0.050981 21.854 < 2e-16 ***
## `% Asian` 0.004990 0.001308 3.816 0.000151 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.6736 on 567 degrees of freedom
## Multiple R-squared: 0.02504, Adjusted R-squared: 0.02332
## F-statistic: 14.56 on 1 and 567 DF, p-value: 0.0001505
# hispanic/latino
sj_dem_distancing_pre_post %>%
ggplot(aes(
x = `% non hispanic/latino`,
y = `% increase in staying completely home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of residents that are not Hispanic or Latino",
y = "Dif in % completely at home after shelter-in-place relative to before",
title = "San Jose: Social Distancing and Hispanic/Latino Residents"
)
hisp_model_dif <- lm(`% increase in staying completely home` ~ `% non hispanic/latino`, sj_dem_distancing_pre_post)
summary(hisp_model_dif)
##
## Call:
## lm(formula = `% increase in staying completely home` ~ `% non hispanic/latino`,
## data = sj_dem_distancing_pre_post)
##
## Residuals:
## Min 1Q Median 3Q Max
## -41.536 -3.920 0.957 5.121 23.810
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 10.78733 1.12400 9.597 <2e-16 ***
## `% non hispanic/latino` 0.22693 0.01568 14.469 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.427 on 567 degrees of freedom
## Multiple R-squared: 0.2697, Adjusted R-squared: 0.2684
## F-statistic: 209.4 on 1 and 567 DF, p-value: < 2.2e-16
hisp_model_frac <- lm(frac_increase ~ `% non hispanic/latino`, sj_dem_distancing_pre_post)
summary(hisp_model_frac)
##
## Call:
## lm(formula = frac_increase ~ `% non hispanic/latino`, data = sj_dem_distancing_pre_post)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.7671 -0.3543 -0.0187 0.2943 2.5558
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.209446 0.077812 2.692 0.00732 **
## `% non hispanic/latino` 0.015678 0.001086 14.440 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5834 on 567 degrees of freedom
## Multiple R-squared: 0.2689, Adjusted R-squared: 0.2676
## F-statistic: 208.5 on 1 and 567 DF, p-value: < 2.2e-16
First with difference in percents.
difs_model <- lm(sj_dem_distancing_pre_post$`% increase in staying completely home` ~ sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`% not speaking spanish` + sj_dem_distancing_pre_post$`percent less than 1` + sj_dem_distancing_pre_post$`percent high speed`)
summary(difs_model)
##
## Call:
## lm(formula = sj_dem_distancing_pre_post$`% increase in staying completely home` ~
## sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`% not speaking spanish` +
## sj_dem_distancing_pre_post$`percent less than 1` + sj_dem_distancing_pre_post$`percent high speed`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -37.172 -3.947 0.889 5.005 20.897
##
## Coefficients:
## Estimate Std. Error
## (Intercept) 5.888624 3.296538
## sj_dem_distancing_pre_post$`% over 125,000` 0.233541 0.024654
## sj_dem_distancing_pre_post$`% not speaking spanish` 0.080083 0.025519
## sj_dem_distancing_pre_post$`percent less than 1` -0.006499 0.043997
## sj_dem_distancing_pre_post$`percent high speed` 0.063404 0.036865
## t value Pr(>|t|)
## (Intercept) 1.786 0.07459 .
## sj_dem_distancing_pre_post$`% over 125,000` 9.473 < 2e-16 ***
## sj_dem_distancing_pre_post$`% not speaking spanish` 3.138 0.00179 **
## sj_dem_distancing_pre_post$`percent less than 1` -0.148 0.88262
## sj_dem_distancing_pre_post$`percent high speed` 1.720 0.08599 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.758 on 564 degrees of freedom
## Multiple R-squared: 0.3843, Adjusted R-squared: 0.3799
## F-statistic: 87.99 on 4 and 564 DF, p-value: < 2.2e-16
Second with fractional change.
frac_model <- lm(sj_dem_distancing_pre_post$frac_increase ~ sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`% not speaking spanish` + sj_dem_distancing_pre_post$`percent less than 1` + sj_dem_distancing_pre_post$`percent high speed`)
summary(frac_model)
##
## Call:
## lm(formula = sj_dem_distancing_pre_post$frac_increase ~ sj_dem_distancing_pre_post$`% over 125,000` +
## sj_dem_distancing_pre_post$`% not speaking spanish` + sj_dem_distancing_pre_post$`percent less than 1` +
## sj_dem_distancing_pre_post$`percent high speed`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.98845 -0.30220 0.01756 0.26994 2.37443
##
## Coefficients:
## Estimate Std. Error
## (Intercept) -0.1122792 0.2251531
## sj_dem_distancing_pre_post$`% over 125,000` 0.0174733 0.0016838
## sj_dem_distancing_pre_post$`% not speaking spanish` 0.0054210 0.0017429
## sj_dem_distancing_pre_post$`percent less than 1` 0.0023581 0.0030050
## sj_dem_distancing_pre_post$`percent high speed` 0.0004595 0.0025178
## t value Pr(>|t|)
## (Intercept) -0.499 0.61820
## sj_dem_distancing_pre_post$`% over 125,000` 10.377 < 2e-16 ***
## sj_dem_distancing_pre_post$`% not speaking spanish` 3.110 0.00196 **
## sj_dem_distancing_pre_post$`percent less than 1` 0.785 0.43295
## sj_dem_distancing_pre_post$`percent high speed` 0.183 0.85525
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5299 on 564 degrees of freedom
## Multiple R-squared: 0.4, Adjusted R-squared: 0.3957
## F-statistic: 94 on 4 and 564 DF, p-value: < 2.2e-16
difs_model_inc_span <- lm(sj_dem_distancing_pre_post$`% increase in staying completely home` ~ sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`% not speaking spanish`)
summary(difs_model_inc_span)
##
## Call:
## lm(formula = sj_dem_distancing_pre_post$`% increase in staying completely home` ~
## sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`% not speaking spanish`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -37.056 -4.101 1.030 5.118 21.602
##
## Coefficients:
## Estimate Std. Error t value
## (Intercept) 8.90321 1.31193 6.786
## sj_dem_distancing_pre_post$`% over 125,000` 0.25153 0.02189 11.493
## sj_dem_distancing_pre_post$`% not speaking spanish` 0.08996 0.02084 4.316
## Pr(>|t|)
## (Intercept) 2.91e-11 ***
## sj_dem_distancing_pre_post$`% over 125,000` < 2e-16 ***
## sj_dem_distancing_pre_post$`% not speaking spanish` 1.87e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.764 on 566 degrees of freedom
## Multiple R-squared: 0.381, Adjusted R-squared: 0.3788
## F-statistic: 174.2 on 2 and 566 DF, p-value: < 2.2e-16
frac_model_inc_span <- lm(sj_dem_distancing_pre_post$frac_increase ~ sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`% not speaking spanish`)
summary(frac_model_inc_span)
##
## Call:
## lm(formula = sj_dem_distancing_pre_post$frac_increase ~ sj_dem_distancing_pre_post$`% over 125,000` +
## sj_dem_distancing_pre_post$`% not speaking spanish`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.99970 -0.29963 0.02114 0.26759 2.38885
##
## Coefficients:
## Estimate Std. Error t value
## (Intercept) 0.053571 0.089426 0.599
## sj_dem_distancing_pre_post$`% over 125,000` 0.017902 0.001492 12.000
## sj_dem_distancing_pre_post$`% not speaking spanish` 0.006268 0.001421 4.412
## Pr(>|t|)
## (Intercept) 0.549
## sj_dem_distancing_pre_post$`% over 125,000` < 2e-16 ***
## sj_dem_distancing_pre_post$`% not speaking spanish` 1.22e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5293 on 566 degrees of freedom
## Multiple R-squared: 0.3992, Adjusted R-squared: 0.3971
## F-statistic: 188.1 on 2 and 566 DF, p-value: < 2.2e-16
When only accounting for for income, Spanish language ability is only slightly relevant, though the result is still nontrivial. Let’s try accounting for both education and income level.
difs_model_inc_span_educ <- lm(sj_dem_distancing_pre_post$`% increase in staying completely home` ~ sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`% not speaking spanish` + sj_dem_distancing_pre_post$`percent associates or higher`)
summary(difs_model_inc_span_educ)
##
## Call:
## lm(formula = sj_dem_distancing_pre_post$`% increase in staying completely home` ~
## sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`% not speaking spanish` +
## sj_dem_distancing_pre_post$`percent associates or higher`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -36.754 -3.631 1.019 5.037 21.054
##
## Coefficients:
## Estimate Std. Error
## (Intercept) 9.91819 1.34021
## sj_dem_distancing_pre_post$`% over 125,000` 0.21759 0.02420
## sj_dem_distancing_pre_post$`% not speaking spanish` 0.03620 0.02672
## sj_dem_distancing_pre_post$`percent associates or higher` 0.09667 0.03045
## t value Pr(>|t|)
## (Intercept) 7.400 4.94e-13 ***
## sj_dem_distancing_pre_post$`% over 125,000` 8.991 < 2e-16 ***
## sj_dem_distancing_pre_post$`% not speaking spanish` 1.355 0.17609
## sj_dem_distancing_pre_post$`percent associates or higher` 3.175 0.00158 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.703 on 565 degrees of freedom
## Multiple R-squared: 0.3919, Adjusted R-squared: 0.3886
## F-statistic: 121.4 on 3 and 565 DF, p-value: < 2.2e-16
frac_model_inc_span_educ <- lm(sj_dem_distancing_pre_post$frac_increase ~ sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`% not speaking spanish` + sj_dem_distancing_pre_post$`percent associates or higher`)
summary(frac_model_inc_span_educ)
##
## Call:
## lm(formula = sj_dem_distancing_pre_post$frac_increase ~ sj_dem_distancing_pre_post$`% over 125,000` +
## sj_dem_distancing_pre_post$`% not speaking spanish` + sj_dem_distancing_pre_post$`percent associates or higher`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.94691 -0.29298 0.00853 0.26299 2.41914
##
## Coefficients:
## Estimate Std. Error
## (Intercept) 0.120677 0.091402
## sj_dem_distancing_pre_post$`% over 125,000` 0.015658 0.001650
## sj_dem_distancing_pre_post$`% not speaking spanish` 0.002714 0.001823
## sj_dem_distancing_pre_post$`percent associates or higher` 0.006391 0.002076
## t value Pr(>|t|)
## (Intercept) 1.320 0.18727
## sj_dem_distancing_pre_post$`% over 125,000` 9.487 < 2e-16 ***
## sj_dem_distancing_pre_post$`% not speaking spanish` 1.489 0.13700
## sj_dem_distancing_pre_post$`percent associates or higher` 3.078 0.00218 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5253 on 565 degrees of freedom
## Multiple R-squared: 0.4092, Adjusted R-squared: 0.406
## F-statistic: 130.4 on 3 and 565 DF, p-value: < 2.2e-16
The effect of Spanish language speaking vanishes when accounting for both education and income.
difs_model_inc_eng_educ <- lm(sj_dem_distancing_pre_post$`% increase in staying completely home` ~ sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`% speaking english > well` + sj_dem_distancing_pre_post$`percent associates or higher`)
summary(difs_model_inc_eng_educ)
##
## Call:
## lm(formula = sj_dem_distancing_pre_post$`% increase in staying completely home` ~
## sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`% speaking english > well` +
## sj_dem_distancing_pre_post$`percent associates or higher`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -38.655 -3.721 1.045 4.889 21.069
##
## Coefficients:
## Estimate Std. Error
## (Intercept) 24.41313 3.70697
## sj_dem_distancing_pre_post$`% over 125,000` 0.23917 0.02411
## sj_dem_distancing_pre_post$`% speaking english > well` -0.18226 0.05007
## sj_dem_distancing_pre_post$`percent associates or higher` 0.17304 0.02710
## t value Pr(>|t|)
## (Intercept) 6.586 1.04e-10 ***
## sj_dem_distancing_pre_post$`% over 125,000` 9.920 < 2e-16 ***
## sj_dem_distancing_pre_post$`% speaking english > well` -3.640 0.000298 ***
## sj_dem_distancing_pre_post$`percent associates or higher` 6.385 3.58e-10 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.627 on 565 degrees of freedom
## Multiple R-squared: 0.4039, Adjusted R-squared: 0.4007
## F-statistic: 127.6 on 3 and 565 DF, p-value: < 2.2e-16
frac_model_inc_eng_educ <- lm(sj_dem_distancing_pre_post$frac_increase ~ sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`% speaking english > well` + sj_dem_distancing_pre_post$`percent associates or higher`)
summary(frac_model_inc_eng_educ)
##
## Call:
## lm(formula = sj_dem_distancing_pre_post$frac_increase ~ sj_dem_distancing_pre_post$`% over 125,000` +
## sj_dem_distancing_pre_post$`% speaking english > well` +
## sj_dem_distancing_pre_post$`percent associates or higher`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.93778 -0.29842 0.01177 0.26564 2.43658
##
## Coefficients:
## Estimate Std. Error
## (Intercept) 0.497226 0.255573
## sj_dem_distancing_pre_post$`% over 125,000` 0.016380 0.001662
## sj_dem_distancing_pre_post$`% speaking english > well` -0.003798 0.003452
## sj_dem_distancing_pre_post$`percent associates or higher` 0.009397 0.001868
## t value Pr(>|t|)
## (Intercept) 1.946 0.0522 .
## sj_dem_distancing_pre_post$`% over 125,000` 9.854 < 2e-16 ***
## sj_dem_distancing_pre_post$`% speaking english > well` -1.100 0.2717
## sj_dem_distancing_pre_post$`percent associates or higher` 5.029 6.62e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5258 on 565 degrees of freedom
## Multiple R-squared: 0.4081, Adjusted R-squared: 0.405
## F-statistic: 129.9 on 3 and 565 DF, p-value: < 2.2e-16
English language ability is actually a slightly better predictor than Spanish language ability, when also accounting for education and income.
difs_model_lots <- lm(sj_dem_distancing_pre_post$`% increase in staying completely home` ~ sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`% speaking english > well` + sj_dem_distancing_pre_post$`percent associates or higher` + sj_dem_distancing_pre_post$`% not speaking spanish` + sj_dem_distancing_pre_post$`percent with vehicles`)
summary(difs_model_lots)
##
## Call:
## lm(formula = sj_dem_distancing_pre_post$`% increase in staying completely home` ~
## sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`% speaking english > well` +
## sj_dem_distancing_pre_post$`percent associates or higher` +
## sj_dem_distancing_pre_post$`% not speaking spanish` +
## sj_dem_distancing_pre_post$`percent with vehicles`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -39.193 -3.558 1.047 4.884 21.144
##
## Coefficients:
## Estimate Std. Error
## (Intercept) 15.31547 5.48658
## sj_dem_distancing_pre_post$`% over 125,000` 0.21569 0.02589
## sj_dem_distancing_pre_post$`% speaking english > well` -0.19520 0.05013
## sj_dem_distancing_pre_post$`percent associates or higher` 0.14682 0.03251
## sj_dem_distancing_pre_post$`% not speaking spanish` 0.04655 0.02647
## sj_dem_distancing_pre_post$`percent with vehicles` 0.09292 0.04703
## t value Pr(>|t|)
## (Intercept) 2.791 0.00543 **
## sj_dem_distancing_pre_post$`% over 125,000` 8.330 6.18e-16 ***
## sj_dem_distancing_pre_post$`% speaking english > well` -3.894 0.00011 ***
## sj_dem_distancing_pre_post$`percent associates or higher` 4.516 7.68e-06 ***
## sj_dem_distancing_pre_post$`% not speaking spanish` 1.759 0.07911 .
## sj_dem_distancing_pre_post$`percent with vehicles` 1.976 0.04869 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.595 on 563 degrees of freedom
## Multiple R-squared: 0.4108, Adjusted R-squared: 0.4056
## F-statistic: 78.51 on 5 and 563 DF, p-value: < 2.2e-16
frac_model_lots <- lm(sj_dem_distancing_pre_post$frac_increase ~ sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`% speaking english > well` + sj_dem_distancing_pre_post$`percent associates or higher` + sj_dem_distancing_pre_post$`% not speaking spanish` + sj_dem_distancing_pre_post$`percent with vehicles`)
summary(frac_model_lots)
##
## Call:
## lm(formula = sj_dem_distancing_pre_post$frac_increase ~ sj_dem_distancing_pre_post$`% over 125,000` +
## sj_dem_distancing_pre_post$`% speaking english > well` +
## sj_dem_distancing_pre_post$`percent associates or higher` +
## sj_dem_distancing_pre_post$`% not speaking spanish` + sj_dem_distancing_pre_post$`percent with vehicles`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.94356 -0.30435 0.00216 0.26876 2.41224
##
## Coefficients:
## Estimate Std. Error
## (Intercept) 0.208851 0.379462
## sj_dem_distancing_pre_post$`% over 125,000` 0.015542 0.001791
## sj_dem_distancing_pre_post$`% speaking english > well` -0.004389 0.003467
## sj_dem_distancing_pre_post$`percent associates or higher` 0.007527 0.002248
## sj_dem_distancing_pre_post$`% not speaking spanish` 0.002957 0.001830
## sj_dem_distancing_pre_post$`percent with vehicles` 0.002458 0.003253
## t value Pr(>|t|)
## (Intercept) 0.550 0.58227
## sj_dem_distancing_pre_post$`% over 125,000` 8.679 < 2e-16 ***
## sj_dem_distancing_pre_post$`% speaking english > well` -1.266 0.20610
## sj_dem_distancing_pre_post$`percent associates or higher` 3.348 0.00087 ***
## sj_dem_distancing_pre_post$`% not speaking spanish` 1.615 0.10677
## sj_dem_distancing_pre_post$`percent with vehicles` 0.756 0.45020
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5253 on 563 degrees of freedom
## Multiple R-squared: 0.4113, Adjusted R-squared: 0.4061
## F-statistic: 78.67 on 5 and 563 DF, p-value: < 2.2e-16
The main important variables are education and income, with potentially some effect of English language ability.
difs_model_inc_educ <- lm(sj_dem_distancing_pre_post$`% increase in staying completely home` ~ sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`percent associates or higher`)
summary(difs_model_inc_educ)
##
## Call:
## lm(formula = sj_dem_distancing_pre_post$`% increase in staying completely home` ~
## sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`percent associates or higher`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -36.671 -3.735 1.128 4.928 20.844
##
## Coefficients:
## Estimate Std. Error
## (Intercept) 11.29393 0.87510
## sj_dem_distancing_pre_post$`% over 125,000` 0.22262 0.02393
## sj_dem_distancing_pre_post$`percent associates or higher` 0.12280 0.02357
## t value Pr(>|t|)
## (Intercept) 12.906 < 2e-16 ***
## sj_dem_distancing_pre_post$`% over 125,000` 9.302 < 2e-16 ***
## sj_dem_distancing_pre_post$`percent associates or higher` 5.209 2.66e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.709 on 566 degrees of freedom
## Multiple R-squared: 0.3899, Adjusted R-squared: 0.3877
## F-statistic: 180.9 on 2 and 566 DF, p-value: < 2.2e-16
frac_model_inc_educ <- lm(sj_dem_distancing_pre_post$`frac_increase` ~ sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`percent associates or higher`)
summary(frac_model_inc_educ)
##
## Call:
## lm(formula = sj_dem_distancing_pre_post$frac_increase ~ sj_dem_distancing_pre_post$`% over 125,000` +
## sj_dem_distancing_pre_post$`percent associates or higher`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.9338 -0.2932 0.0080 0.2672 2.4497
##
## Coefficients:
## Estimate Std. Error
## (Intercept) 0.223825 0.059702
## sj_dem_distancing_pre_post$`% over 125,000` 0.016035 0.001633
## sj_dem_distancing_pre_post$`percent associates or higher` 0.008350 0.001608
## t value Pr(>|t|)
## (Intercept) 3.749 0.000196 ***
## sj_dem_distancing_pre_post$`% over 125,000` 9.821 < 2e-16 ***
## sj_dem_distancing_pre_post$`percent associates or higher` 5.192 2.9e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5259 on 566 degrees of freedom
## Multiple R-squared: 0.4068, Adjusted R-squared: 0.4047
## F-statistic: 194.1 on 2 and 566 DF, p-value: < 2.2e-16
Comparing this to earlier models, we see that adding the English language ability variable does add some predictive power, though not much, and adding the vehicle ownership and Spanish language ability variables have negligible effects.
We now consider adding race into the regressions.
difs_model_inc_hisp <- lm(sj_dem_distancing_pre_post$`% increase in staying completely home` ~ sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`% non hispanic/latino`)
summary(difs_model_inc_hisp)
##
## Call:
## lm(formula = sj_dem_distancing_pre_post$`% increase in staying completely home` ~
## sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`% non hispanic/latino`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -37.105 -3.779 1.002 5.099 20.657
##
## Coefficients:
## Estimate Std. Error t value
## (Intercept) 9.79763 1.03125 9.501
## sj_dem_distancing_pre_post$`% over 125,000` 0.23490 0.02209 10.635
## sj_dem_distancing_pre_post$`% non hispanic/latino` 0.09968 0.01867 5.340
## Pr(>|t|)
## (Intercept) < 2e-16 ***
## sj_dem_distancing_pre_post$`% over 125,000` < 2e-16 ***
## sj_dem_distancing_pre_post$`% non hispanic/latino` 1.35e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.7 on 566 degrees of freedom
## Multiple R-squared: 0.3913, Adjusted R-squared: 0.3892
## F-statistic: 181.9 on 2 and 566 DF, p-value: < 2.2e-16
frac_model_inc_hisp <- lm(sj_dem_distancing_pre_post$frac_increase ~ sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`% non hispanic/latino`)
summary(frac_model_inc_hisp)
##
## Call:
## lm(formula = sj_dem_distancing_pre_post$frac_increase ~ sj_dem_distancing_pre_post$`% over 125,000` +
## sj_dem_distancing_pre_post$`% non hispanic/latino`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.0007 -0.3147 0.0192 0.2745 2.4204
##
## Coefficients:
## Estimate Std. Error t value
## (Intercept) 0.137068 0.070560 1.943
## sj_dem_distancing_pre_post$`% over 125,000` 0.017179 0.001511 11.367
## sj_dem_distancing_pre_post$`% non hispanic/latino` 0.006372 0.001277 4.989
## Pr(>|t|)
## (Intercept) 0.0526 .
## sj_dem_distancing_pre_post$`% over 125,000` < 2e-16 ***
## sj_dem_distancing_pre_post$`% non hispanic/latino` 8.1e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5268 on 566 degrees of freedom
## Multiple R-squared: 0.4048, Adjusted R-squared: 0.4026
## F-statistic: 192.4 on 2 and 566 DF, p-value: < 2.2e-16
difs_model_inc_hisp_educ <- lm(sj_dem_distancing_pre_post$`% increase in staying completely home` ~ sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`% non hispanic/latino` + sj_dem_distancing_pre_post$`percent associates or higher`)
summary(difs_model_inc_hisp_educ)
##
## Call:
## lm(formula = sj_dem_distancing_pre_post$`% increase in staying completely home` ~
## sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`% non hispanic/latino` +
## sj_dem_distancing_pre_post$`percent associates or higher`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -37.096 -3.705 1.041 5.109 20.632
##
## Coefficients:
## Estimate Std. Error
## (Intercept) 9.94688 1.03023
## sj_dem_distancing_pre_post$`% over 125,000` 0.21367 0.02410
## sj_dem_distancing_pre_post$`% non hispanic/latino` 0.06225 0.02541
## sj_dem_distancing_pre_post$`percent associates or higher` 0.06934 0.03205
## t value Pr(>|t|)
## (Intercept) 9.655 <2e-16 ***
## sj_dem_distancing_pre_post$`% over 125,000` 8.864 <2e-16 ***
## sj_dem_distancing_pre_post$`% non hispanic/latino` 2.450 0.0146 *
## sj_dem_distancing_pre_post$`percent associates or higher` 2.164 0.0309 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.675 on 565 degrees of freedom
## Multiple R-squared: 0.3963, Adjusted R-squared: 0.3931
## F-statistic: 123.6 on 3 and 565 DF, p-value: < 2.2e-16
frac_model_inc_hisp_educ <- lm(sj_dem_distancing_pre_post$frac_increase ~ sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`% non hispanic/latino` + sj_dem_distancing_pre_post$`percent associates or higher`)
summary(frac_model_inc_hisp_educ)
##
## Call:
## lm(formula = sj_dem_distancing_pre_post$frac_increase ~ sj_dem_distancing_pre_post$`% over 125,000` +
## sj_dem_distancing_pre_post$`% non hispanic/latino` + sj_dem_distancing_pre_post$`percent associates or higher`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.95568 -0.29408 0.00776 0.26293 2.42973
##
## Coefficients:
## Estimate Std. Error
## (Intercept) 0.148617 0.070408
## sj_dem_distancing_pre_post$`% over 125,000` 0.015536 0.001647
## sj_dem_distancing_pre_post$`% non hispanic/latino` 0.003476 0.001736
## sj_dem_distancing_pre_post$`percent associates or higher` 0.005366 0.002190
## t value Pr(>|t|)
## (Intercept) 2.111 0.0352 *
## sj_dem_distancing_pre_post$`% over 125,000` 9.430 <2e-16 ***
## sj_dem_distancing_pre_post$`% non hispanic/latino` 2.002 0.0458 *
## sj_dem_distancing_pre_post$`percent associates or higher` 2.450 0.0146 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5245 on 565 degrees of freedom
## Multiple R-squared: 0.411, Adjusted R-squared: 0.4079
## F-statistic: 131.4 on 3 and 565 DF, p-value: < 2.2e-16
When including education, percentage of Hispanic/Latino residents loses as much of its predictive power.
difs_model_inc_white_educ <- lm(sj_dem_distancing_pre_post$`% increase in staying completely home` ~ sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`% white` + sj_dem_distancing_pre_post$`percent associates or higher`)
summary(difs_model_inc_white_educ)
##
## Call:
## lm(formula = sj_dem_distancing_pre_post$`% increase in staying completely home` ~
## sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`% white` +
## sj_dem_distancing_pre_post$`percent associates or higher`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -36.485 -3.912 1.201 4.756 17.949
##
## Coefficients:
## Estimate Std. Error
## (Intercept) 12.84118 0.94702
## sj_dem_distancing_pre_post$`% over 125,000` 0.23025 0.02370
## sj_dem_distancing_pre_post$`% white` -0.06215 0.01559
## sj_dem_distancing_pre_post$`percent associates or higher` 0.14009 0.02367
## t value Pr(>|t|)
## (Intercept) 13.560 < 2e-16 ***
## sj_dem_distancing_pre_post$`% over 125,000` 9.715 < 2e-16 ***
## sj_dem_distancing_pre_post$`% white` -3.986 7.60e-05 ***
## sj_dem_distancing_pre_post$`percent associates or higher` 5.918 5.64e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.609 on 565 degrees of freedom
## Multiple R-squared: 0.4066, Adjusted R-squared: 0.4034
## F-statistic: 129 on 3 and 565 DF, p-value: < 2.2e-16
frac_model_inc_white_educ <- lm(sj_dem_distancing_pre_post$frac_increase ~ sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`% white` + sj_dem_distancing_pre_post$`percent associates or higher`)
summary(frac_model_inc_white_educ)
##
## Call:
## lm(formula = sj_dem_distancing_pre_post$frac_increase ~ sj_dem_distancing_pre_post$`% over 125,000` +
## sj_dem_distancing_pre_post$`% white` + sj_dem_distancing_pre_post$`percent associates or higher`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.93848 -0.29364 0.00696 0.26663 2.44543
##
## Coefficients:
## Estimate Std. Error
## (Intercept) 0.2204243 0.0655094
## sj_dem_distancing_pre_post$`% over 125,000` 0.0160183 0.0016395
## sj_dem_distancing_pre_post$`% white` 0.0001366 0.0010786
## sj_dem_distancing_pre_post$`percent associates or higher` 0.0083123 0.0016373
## t value Pr(>|t|)
## (Intercept) 3.365 0.000818 ***
## sj_dem_distancing_pre_post$`% over 125,000` 9.770 < 2e-16 ***
## sj_dem_distancing_pre_post$`% white` 0.127 0.899277
## sj_dem_distancing_pre_post$`percent associates or higher` 5.077 5.22e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5264 on 565 degrees of freedom
## Multiple R-squared: 0.4068, Adjusted R-squared: 0.4037
## F-statistic: 129.2 on 3 and 565 DF, p-value: < 2.2e-16
difs_model_inc_asian_educ <- lm(sj_dem_distancing_pre_post$`% increase in staying completely home` ~ sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`% Asian` + sj_dem_distancing_pre_post$`percent associates or higher`)
summary(difs_model_inc_asian_educ)
##
## Call:
## lm(formula = sj_dem_distancing_pre_post$`% increase in staying completely home` ~
## sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`% Asian` +
## sj_dem_distancing_pre_post$`percent associates or higher`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -36.827 -3.820 1.117 4.945 18.232
##
## Coefficients:
## Estimate Std. Error
## (Intercept) 9.89236 0.90531
## sj_dem_distancing_pre_post$`% over 125,000` 0.21941 0.02348
## sj_dem_distancing_pre_post$`% Asian` 0.07363 0.01515
## sj_dem_distancing_pre_post$`percent associates or higher` 0.10464 0.02342
## t value Pr(>|t|)
## (Intercept) 10.927 < 2e-16 ***
## sj_dem_distancing_pre_post$`% over 125,000` 9.346 < 2e-16 ***
## sj_dem_distancing_pre_post$`% Asian` 4.859 1.53e-06 ***
## sj_dem_distancing_pre_post$`percent associates or higher` 4.469 9.52e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.559 on 565 degrees of freedom
## Multiple R-squared: 0.4144, Adjusted R-squared: 0.4113
## F-statistic: 133.3 on 3 and 565 DF, p-value: < 2.2e-16
frac_model_inc_asian_educ <- lm(sj_dem_distancing_pre_post$frac_increase ~ sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`% Asian` + sj_dem_distancing_pre_post$`percent associates or higher`)
summary(frac_model_inc_asian_educ)
##
## Call:
## lm(formula = sj_dem_distancing_pre_post$frac_increase ~ sj_dem_distancing_pre_post$`% over 125,000` +
## sj_dem_distancing_pre_post$`% Asian` + sj_dem_distancing_pre_post$`percent associates or higher`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.9226 -0.2970 0.0086 0.2624 2.4582
##
## Coefficients:
## Estimate Std. Error
## (Intercept) 0.2158062 0.0630309
## sj_dem_distancing_pre_post$`% over 125,000` 0.0160168 0.0016345
## sj_dem_distancing_pre_post$`% Asian` 0.0004213 0.0010550
## sj_dem_distancing_pre_post$`percent associates or higher` 0.0082464 0.0016303
## t value Pr(>|t|)
## (Intercept) 3.424 0.000662 ***
## sj_dem_distancing_pre_post$`% over 125,000` 9.799 < 2e-16 ***
## sj_dem_distancing_pre_post$`% Asian` 0.399 0.689844
## sj_dem_distancing_pre_post$`percent associates or higher` 5.058 5.73e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5263 on 565 degrees of freedom
## Multiple R-squared: 0.407, Adjusted R-squared: 0.4038
## F-statistic: 129.3 on 3 and 565 DF, p-value: < 2.2e-16
difs_model_inc_asian_educ_eng <- lm(sj_dem_distancing_pre_post$`% increase in staying completely home` ~ sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`% Asian` + sj_dem_distancing_pre_post$`percent associates or higher` + sj_dem_distancing_pre_post$`% speaking english > well`)
summary(difs_model_inc_asian_educ_eng)
##
## Call:
## lm(formula = sj_dem_distancing_pre_post$`% increase in staying completely home` ~
## sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`% Asian` +
## sj_dem_distancing_pre_post$`percent associates or higher` +
## sj_dem_distancing_pre_post$`% speaking english > well`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -37.412 -3.830 1.057 4.842 18.327
##
## Coefficients:
## Estimate Std. Error
## (Intercept) 14.10713 4.82041
## sj_dem_distancing_pre_post$`% over 125,000` 0.22493 0.02429
## sj_dem_distancing_pre_post$`% Asian` 0.06323 0.01914
## sj_dem_distancing_pre_post$`percent associates or higher` 0.12258 0.03090
## sj_dem_distancing_pre_post$`% speaking english > well` -0.05580 0.06269
## t value Pr(>|t|)
## (Intercept) 2.927 0.00357 **
## sj_dem_distancing_pre_post$`% over 125,000` 9.261 < 2e-16 ***
## sj_dem_distancing_pre_post$`% Asian` 3.304 0.00101 **
## sj_dem_distancing_pre_post$`percent associates or higher` 3.967 8.23e-05 ***
## sj_dem_distancing_pre_post$`% speaking english > well` -0.890 0.37373
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.561 on 564 degrees of freedom
## Multiple R-squared: 0.4152, Adjusted R-squared: 0.411
## F-statistic: 100.1 on 4 and 564 DF, p-value: < 2.2e-16
frac_model_inc_asian_educ_eng <- lm(sj_dem_distancing_pre_post$frac_increase ~ sj_dem_distancing_pre_post$`% over 125,000` + sj_dem_distancing_pre_post$`% Asian` + sj_dem_distancing_pre_post$`percent associates or higher` + sj_dem_distancing_pre_post$`% speaking english > well`)
summary(frac_model_inc_asian_educ_eng)
##
## Call:
## lm(formula = sj_dem_distancing_pre_post$frac_increase ~ sj_dem_distancing_pre_post$`% over 125,000` +
## sj_dem_distancing_pre_post$`% Asian` + sj_dem_distancing_pre_post$`percent associates or higher` +
## sj_dem_distancing_pre_post$`% speaking english > well`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.95085 -0.29845 0.01225 0.26295 2.42410
##
## Coefficients:
## Estimate Std. Error
## (Intercept) 0.5717896 0.3355027
## sj_dem_distancing_pre_post$`% over 125,000` 0.0164831 0.0016904
## sj_dem_distancing_pre_post$`% Asian` -0.0004575 0.0013321
## sj_dem_distancing_pre_post$`percent associates or higher` 0.0097624 0.0021509
## sj_dem_distancing_pre_post$`% speaking english > well` -0.0047132 0.0043629
## t value Pr(>|t|)
## (Intercept) 1.704 0.0889 .
## sj_dem_distancing_pre_post$`% over 125,000` 9.751 < 2e-16 ***
## sj_dem_distancing_pre_post$`% Asian` -0.343 0.7314
## sj_dem_distancing_pre_post$`percent associates or higher` 4.539 6.92e-06 ***
## sj_dem_distancing_pre_post$`% speaking english > well` -1.080 0.2805
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.5262 on 564 degrees of freedom
## Multiple R-squared: 0.4082, Adjusted R-squared: 0.404
## F-statistic: 97.27 on 4 and 564 DF, p-value: < 2.2e-16
From the results presented above, we see that income (making over $125,000) predicts about 36% of the variability in percent of devices leaving the home across blockgroups. Adding in education leads to a prediction of about 39% of the variation, and including percent of residents that are Asian with both education and income adds about 2% predictive power. Additional variables on top of these three negligibly increase the percent of variation in the data that the variables explain.
# another collection for pre shelter in place behavior
sj_dem_distancing_pre_shelter <- sj_dem_distancing %>%
dplyr::select(-`% not completely at home`) %>%
left_join(sj_internet_by_block %>% dplyr::select(`% not completely at home pre shelter`, blockgroup))
# relabel column for leaving home
colnames(sj_dem_distancing_pre_shelter)[18] <- "% not completely at home"
sj_dem_distancing[is.na(sj_dem_distancing)] <- 0
sj_dem_distancing_pre_shelter[is.na(sj_dem_distancing_pre_shelter)] <- 0
# add column indicating before or after shelter in place, then bind the two sets of data
sj_dem_distancing_pre_shelter <- sj_dem_distancing_pre_shelter %>%
mutate(
income_trendline =
fitted(lm(sj_dem_distancing_pre_shelter$`% not completely at home` ~ sj_dem_distancing_pre_shelter$`% over 125,000`))
) %>%
cbind(`Before or After Shelter-in-Place` = "before")
sj_dem_distancing <-
sj_dem_distancing %>%
mutate(
income_trendline =
fitted(lm(sj_dem_distancing$`% not completely at home` ~ sj_dem_distancing$`% over 125,000`))
) %>%
cbind(`Before or After Shelter-in-Place` = "after") %>%
rbind(sj_dem_distancing_pre_shelter)
# try animating
fig <-
plot_ly (sj_dem_distancing) %>%
add_trace(
x = ~`% over 125,000`,
y = ~`% not completely at home`,
frame = ~`Before or After Shelter-in-Place`,
type = 'scatter',
mode = 'markers'
) %>%
add_trace(
x = ~`% over 125,000`,
y = ~income_trendline,
type = 'scatter',
mode = 'lines',
line = list(size = 5, color = 'rgba(255, 165, 0, 1)'),
frame = ~`Before or After Shelter-in-Place`
) %>%
animation_button(visible = F)
fig
# # save as rds
# saveRDS(sj_dem_distancing, "/Users/simonespeizer/pCloud Drive/Shared/SFBI/Restricted Data Library/Safegraph/covid19analysis/sj_sd_dem_data.rds")
# fig <- plot_ly(sj_dem_distancing) %>%
# add_trace(
# x = ~`% over 125,000`,
# y = ~`% not completely at home`,
# frame = ~`Before or After Shelter-in-Place`,
# type = "scatter",
# mode = "markers",
# name = "Under $125,000",
# marker = list(size = 5, color = 'rgba(50, 150, 200, 1)'),
# visible = T
# ) %>%
# add_trace(
# x = ~`% over 125,000`,
# y = fitted(lm(sj_dem_distancing$`% not completely at home` ~ sj_dem_distancing$`% over 125,000`)),
# name = 'trendline',
# mode = 'lines',
# line = list(size = 5, color = 'rgba(255, 165, 0, 1)'),
# frame = ~`Before or After Shelter-in-Place`,
# visible = F
# ) %>%
# add_trace(
# x = ~`% not speaking spanish`,
# y = ~`% not completely at home`,
# frame = ~`Before or After Shelter-in-Place`,
# name = "speak spanish",
# marker = list(size = 5, color = 'rgba(50, 150, 200, 1)'),
# visible = F
# ) %>%
# add_trace(
# x = ~`% not speaking spanish`,
# y = fitted(lm(sj_dem_distancing$`% not completely at home` ~ sj_dem_distancing$`% not speaking spanish`)),
# name = 'trendline',
# mode = 'lines',
# line = list(size = 5, color = 'rgba(255, 165, 0, 1)'),
# frame = ~`Before or After Shelter-in-Place`,
# visible = F
# ) %>%
# add_trace(
# x = ~`percent associates or higher`,
# y = ~`% not completely at home`,
# frame = ~`Before or After Shelter-in-Place`,
# name = "percent higher degree",
# marker = list(size = 5, color = 'rgba(50, 150, 200, 1)'),
# visible = F
# ) %>%
# add_trace(
# x = ~`percent associates or higher`,
# y = fitted(lm(sj_dem_distancing$`% not completely at home` ~ sj_dem_distancing$`percent associates or higher`)),
# name = 'trendline',
# mode = 'lines',
# line = list(size = 5, color = 'rgba(255, 165, 0, 1)'),
# frame = ~`Before or After Shelter-in-Place`,
# visible = F
# ) %>%
# add_trace(
# x = ~`percent high speed`,
# y = ~`% not completely at home`,
# frame = ~`Before or After Shelter-in-Place`,
# name = "percent high speed internet access",
# marker = list(size = 5, color = 'rgba(50, 150, 200, 1)'),
# visible = F
# ) %>%
# add_trace(
# x = ~`percent high speed`,
# y = fitted(lm(sj_dem_distancing$`% not completely at home` ~ sj_dem_distancing$`percent high speed`)),
# name = 'trendline',
# mode = 'lines',
# line = list(size = 5, color = 'rgba(255, 165, 0, 1)'),
# frame = ~sj_dem_distancing$`Before or After Shelter-in-Place`,
# visible = F
# ) %>%
# add_trace(
# x = ~`percent less than 30`,
# y = ~`% not completely at home`,
# frame = ~`Before or After Shelter-in-Place`,
# name = "percent less than 30",
# marker = list(size = 5, color = 'rgba(50, 150, 200, 1)'),
# visible = F
# ) %>%
# add_trace(
# x = ~`percent less than 30`,
# y = fitted(lm(sj_dem_distancing$`% not completely at home` ~ sj_dem_distancing$`percent less than 30`)),
# name = 'trendline',
# mode = 'lines',
# line = list(size = 5, color = 'rgba(255, 165, 0, 1)'),
# frame = ~`Before or After Shelter-in-Place`,
# visible = F
# ) %>%
# layout(
# updatemenus = list(
# list(
# active = 0,
# type = 'buttons',
# buttons = list(
# list(
# label = "Households Under $125,000",
# method = 'update',
# args = list(list(visible = c(T, T, F, F, F, F, F, F, F, F)),
# list(title = "Under $125,000",
# xaxis = list(title = "% Households Under $125,000 in Income")))),
# list(
# label = "Speaking Spanish",
# method = 'update',
# args = list(list(visible = c(F, F, T, T, F, F, F, F, F, F)),
# list(title = "Not Speaking Spanish",
# xaxis = list(title = "% Residents Not Speaking Spanish")))),
# list(
# label = "Education Level",
# method = 'update',
# args= list(list(visible = c(F, F, F, F, T, T, F, F, F, F)),
# list(xaxis = list(title = "% Residents With Associate's Degree or Higher")))),
# list(
# label = "High Speed Internet",
# method = 'update',
# args= list(list(visible = c(F, F, F, F, F, F, T, T, F, F)),
# list(xaxis = list(title = "% Households With High Speed Internet Access")))),
# list(
# label = "Young Population",
# method = 'update',
# args= list(list(visible = c(F, F, F, F, F, F, T, T, F, F)),
# list(xaxis = list(title = "% Residents Under Age 30"))))
# )
# )
# ),
# yaxis = list(title = "% Residents Leaving Home",
# font = list(size = 15)),
# showlegend = FALSE
# )
# fig
Experimentation with other variables and other ways of analyzing the social distancing data. First I look at a few other possible variables. I start with units in the structure.
# try getting other variables
# get data on units in structure
sj_units_in_structure_by_block <- getCensus(
name = "acs/acs5",
vintage = 2018,
region = "block group:*",
regionin = "state:06+county:085",
vars = "group(B25024)"
) %>%
mutate(
blockgroup =
paste0(state,county,tract,block_group)
) %>%
select_if(!names(.) %in% c("GEO_ID","state","county","tract","block_group","NAME")) %>%
select(-c(contains("EA"),contains("MA"),contains("M"))) %>%
gather(key = "variable", value = "estimate", -blockgroup) %>%
mutate(label = acs_vars$label[match(variable,acs_vars$name)]) %>%
select(-variable) %>%
separate(label, into = c(NA, NA, "units"), sep = "!!") %>%
filter(!is.na(units)) %>%
spread(key = units, value = estimate) %>%
mutate(total_nums = `1, attached` + `1, detached` + `10 to 19` + `2` + `20 to 49`+ `3 or 4` + `5 to 9`+ `50 or more`+ `Boat, RV, van, etc.`+ `Mobile home`, `percent 20 or more` = (`20 to 49`+`50 or more`)* 100/ total_nums, `percent 1 only` = (`1, attached` + `1, detached`)*100/total_nums, `percent > 1` = 100 - `percent 1 only`) %>%
left_join(sj_age_by_block %>% dplyr::select_if(!names(.) %in% c("elderly", "percent elderly", "less than 30", "percent less than 30"))) %>%
filter(!is.na(device_count))
# plot
sj_units_in_structure_by_block %>%
ggplot(aes(
x = `percent 20 or more`,
y = `% not completely at home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of structures with more than 20 units",
y = "Percent devices leaving home on weekdays since shelter-in-place",
title = "San Jose: Social Distancing and 20 or More Units Per Structure"
)
summary(lm(`% not completely at home` ~ `percent 20 or more`, sj_units_in_structure_by_block))
##
## Call:
## lm(formula = `% not completely at home` ~ `percent 20 or more`,
## data = sj_units_in_structure_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -26.551 -5.052 -0.451 4.274 37.149
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 51.15091 0.40431 126.513 <2e-16 ***
## `percent 20 or more` 0.01873 0.02026 0.924 0.356
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.354 on 566 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.001507, Adjusted R-squared: -0.0002566
## F-statistic: 0.8545 on 1 and 566 DF, p-value: 0.3557
sj_units_in_structure_by_block %>%
ggplot(aes(
x = `percent 1 only`,
y = `% not completely at home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of structures with only one unit",
y = "Percent devices leaving home on weekdays since shelter-in-place",
title = "San Jose: Social Distancing and Only 1 Unit Per Structure"
)
summary(lm(`% not completely at home` ~ `percent 1 only`, sj_units_in_structure_by_block))
##
## Call:
## lm(formula = `% not completely at home` ~ `percent 1 only`, data = sj_units_in_structure_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -25.452 -5.117 -0.322 4.364 38.053
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 55.38663 0.88348 62.692 < 2e-16 ***
## `percent 1 only` -0.05596 0.01125 -4.975 8.68e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.184 on 566 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.04189, Adjusted R-squared: 0.0402
## F-statistic: 24.75 on 1 and 566 DF, p-value: 8.681e-07
Household type and size:
# load data on household type and size
sj_house_size_type_by_block <- getCensus(
name = "acs/acs5",
vintage = 2018,
region = "block group:*",
regionin = "state:06+county:085",
vars = "group(B11016)"
) %>%
mutate(
blockgroup =
paste0(state,county,tract,block_group)
) %>%
select_if(!names(.) %in% c("GEO_ID","state","county","tract","block_group","NAME")) %>%
select(-c(contains("EA"),contains("MA"),contains("M"))) %>%
gather(key = "variable", value = "estimate", -blockgroup) %>%
mutate(label = acs_vars$label[match(variable,acs_vars$name)]) %>%
select(-variable) %>%
separate(label, into = c(NA, NA, "type", "size"), sep = "!!") %>%
filter(!is.na(type))
# household type
sj_house_type_by_block <- sj_house_size_type_by_block %>%
filter(is.na(size)) %>%
dplyr::select(-size) %>%
spread(key = type, value = estimate) %>%
mutate(`total households` = `Family households` + `Nonfamily households`, `percent nonfamily` = `Nonfamily households` / `total households`) %>%
left_join(sj_age_by_block %>% dplyr::select_if(!names(.) %in% c("elderly", "percent elderly", "less than 30", "percent less than 30"))) %>%
filter(!is.na(device_count))
sj_house_type_by_block %>%
ggplot(aes(
x = `percent nonfamily`,
y = `% not completely at home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent nonfamily households",
y = "Percent devices leaving home on weekdays since shelter-in-place",
title = "San Jose: Social Distancing and Household Type"
)
summary(lm(`% not completely at home` ~ `percent nonfamily`, sj_house_type_by_block))
##
## Call:
## lm(formula = `% not completely at home` ~ `percent nonfamily`,
## data = sj_house_type_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -24.616 -5.108 -0.157 4.261 39.714
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 48.8864 0.6327 77.262 < 2e-16 ***
## `percent nonfamily` 10.1400 2.1962 4.617 4.82e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.208 on 566 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.0363, Adjusted R-squared: 0.03459
## F-statistic: 21.32 on 1 and 566 DF, p-value: 4.82e-06
# household size
sj_house_size_by_block <- sj_house_size_type_by_block %>%
filter(!is.na(size)) %>%
dplyr::select(-type) %>%
group_by(blockgroup, size) %>%
summarize(`total of this size` = sum(estimate)) %>%
spread(key = size, value = `total of this size`) %>%
mutate(total_nums = `1-person household` + `2-person household` + `3-person household` + `4-person household` + `5-person household`+ `6-person household` + `7-or-more person household`, `percent 5 or more` = (`5-person household`+`6-person household` + `7-or-more person household`)* 100/ total_nums, `percent 1 or 2 only` = (`1-person household` + `2-person household`)*100/total_nums) %>%
left_join(sj_age_by_block %>% dplyr::select_if(!names(.) %in% c("elderly", "percent elderly", "less than 30", "percent less than 30"))) %>%
filter(!is.na(device_count))
sj_house_size_by_block %>%
ggplot(aes(
x = `percent 5 or more`,
y = `% not completely at home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of households with 5 or more people",
y = "Percent devices leaving home on weekdays since shelter-in-place",
title = "San Jose: Social Distancing and Households With 5 or More"
)
summary(lm(`% not completely at home` ~ `percent 5 or more`, sj_house_size_by_block))
##
## Call:
## lm(formula = `% not completely at home` ~ `percent 5 or more`,
## data = sj_house_size_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -26.136 -4.979 -0.518 4.175 36.154
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 49.85951 0.56004 89.028 < 2e-16 ***
## `percent 5 or more` 0.08454 0.02513 3.364 0.000821 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.278 on 566 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.0196, Adjusted R-squared: 0.01786
## F-statistic: 11.31 on 1 and 566 DF, p-value: 0.0008215
sj_house_size_by_block %>%
ggplot(aes(
x = `percent 1 or 2 only`,
y = `% not completely at home`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of households with 1 or 2 people",
y = "Percent devices leaving home on weekdays since shelter-in-place",
title = "San Jose: Social Distancing and Small Household Size"
)
summary(lm(`% not completely at home` ~ `percent 1 or 2 only`, sj_house_size_by_block))
##
## Call:
## lm(formula = `% not completely at home` ~ `percent 1 or 2 only`,
## data = sj_house_size_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -25.847 -5.127 -0.450 4.596 37.830
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 50.13694 0.96771 51.81 <2e-16 ***
## `percent 1 or 2 only` 0.02678 0.02013 1.33 0.184
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.348 on 566 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.003118, Adjusted R-squared: 0.001356
## F-statistic: 1.77 on 1 and 566 DF, p-value: 0.1839
Next I consider different ways of looking at the social distancing data. First I try distance traveled.
# try other ways of looking at the social distancing data
# first look at total distance traveled
sj_sd_distance <- sj_socialdistancing %>%
filter(date > shelter_start) %>%
group_by(origin_census_block_group) %>%
summarize(total_dist_traveled = sum(distance_traveled_from_home), device_count = sum(device_count)) %>%
mutate(total_dist_per_device = total_dist_traveled / device_count)
sj_distance_testing <- left_join(sj_ami_by_block, sj_sd_distance, by = c("blockgroup" = "origin_census_block_group")) %>% left_join(sj_age_by_block %>% select(blockgroup, `percent less than 30`))
sj_distance_testing %>% filter(total_dist_per_device < 500) %>%
ggplot(aes(
x = `% over 75,000`,
y = total_dist_per_device
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of housholds with incomes over $75,000 (50% AMI) annually",
y = "Average distance traveled per device during weekdays since shelter-in-place",
title = "San Jose: Social Distancing and Income, Distance Metric"
)
This is very skewed by outliers, and probably not a useful metric.
Now I consider including devices that traveled <1km as staying at (or near) home.
sj_sd_range <- sj_socialdistancing %>%
filter(weekend == F) %>%
filter(date > shelter_start) %>%
mutate(travel_buckets_split = lapply(bucketed_distance_traveled, function(x) strsplit(x, "<1000")[[1]][2]), less_than_1km = lapply(travel_buckets_split, function(x) strsplit(x, ":")[[1]][2]), less_than_1km = lapply(less_than_1km, function(x) strsplit(x, ",")[[1]][1])) %>%
mutate(less_than_1km = lapply(less_than_1km, function(x) str_remove(x, "[}]"))) %>% # clean a bit more
mutate(less_than_1km = as.numeric(less_than_1km), less_than_1km = replace_na(less_than_1km, 0)) %>%
mutate(home_or_1km = completely_home_device_count + less_than_1km) %>%
group_by(origin_census_block_group) %>%
summarize(home_or_1km = sum(home_or_1km), device_count = sum(device_count)) %>%
mutate(`% Within 1km of Home` = (home_or_1km/device_count*100) %>% round(1), `% farther than 1km` = (100-`% Within 1km of Home`))
# join this with other data
sj_1km_testing <- left_join(sj_ami_by_block, sj_sd_range, by = c("blockgroup" = "origin_census_block_group")) %>%
left_join(sj_occupants_per_room_by_block %>% dplyr::select(`percent less than 1`, blockgroup)) %>%
left_join(sj_age_by_block %>% dplyr::select(`percent less than 30`, blockgroup)) %>%
left_join(sj_lang_by_block %>% dplyr::select(`% speaking english > well`, blockgroup))
# plot with income
sj_1km_testing %>%
ggplot(aes(
x = `% over 75,000`,
y = `% farther than 1km`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of housholds with incomes over $75,000 (50% AMI) annually",
y = "% of devices going farther than 1km of home, weekdays since shelter-in-place",
title = "San Jose: Social Distancing and Income, 1km Range"
)
summary(lm(`% farther than 1km` ~ `% over 75,000`, sj_1km_testing))
##
## Call:
## lm(formula = `% farther than 1km` ~ `% over 75,000`, data = sj_1km_testing)
##
## Residuals:
## Min 1Q Median 3Q Max
## -21.389 -4.795 -0.606 4.185 34.925
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 64.35928 1.11518 57.71 <2e-16 ***
## `% over 75,000` -0.20909 0.01719 -12.16 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.444 on 566 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.2072, Adjusted R-squared: 0.2058
## F-statistic: 148 on 1 and 566 DF, p-value: < 2.2e-16
# plot with age
sj_1km_testing %>%
ggplot(aes(
x = `percent less than 30`,
y = `% farther than 1km`
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of people younger than 30",
y = "Percent of devices farther than 1km of home during weekdays since shelter-in-place",
title = "San Jose: Social Distancing and Age, 1km Range"
)
summary(lm(`% farther than 1km` ~ `percent less than 30`, sj_1km_testing))
##
## Call:
## lm(formula = `% farther than 1km` ~ `percent less than 30`, data = sj_1km_testing)
##
## Residuals:
## Min 1Q Median 3Q Max
## -28.505 -4.978 -0.362 4.274 39.808
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 44.49223 1.51348 29.397 < 2e-16 ***
## `percent less than 30` 0.17973 0.03836 4.685 3.51e-06 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 8.299 on 567 degrees of freedom
## Multiple R-squared: 0.03726, Adjusted R-squared: 0.03557
## F-statistic: 21.95 on 1 and 567 DF, p-value: 3.513e-06
# run multiple regression model
modeltest2 <- lm(sj_1km_testing$`% farther than 1km` ~ sj_1km_testing$`% over 75,000` + sj_1km_testing$`percent less than 30` + sj_1km_testing$`% speaking english > well` + sj_1km_testing$`percent less than 1`)
summary(modeltest2)
##
## Call:
## lm(formula = sj_1km_testing$`% farther than 1km` ~ sj_1km_testing$`% over 75,000` +
## sj_1km_testing$`percent less than 30` + sj_1km_testing$`% speaking english > well` +
## sj_1km_testing$`percent less than 1`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -20.646 -4.675 -0.762 4.296 34.809
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 58.57603 4.69256 12.483 <2e-16
## sj_1km_testing$`% over 75,000` -0.21745 0.02166 -10.039 <2e-16
## sj_1km_testing$`percent less than 30` 0.03813 0.04267 0.894 0.3718
## sj_1km_testing$`% speaking english > well` 0.09468 0.04607 2.055 0.0403
## sj_1km_testing$`percent less than 1` -0.03946 0.04679 -0.843 0.3994
##
## (Intercept) ***
## sj_1km_testing$`% over 75,000` ***
## sj_1km_testing$`percent less than 30`
## sj_1km_testing$`% speaking english > well` *
## sj_1km_testing$`percent less than 1`
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.424 on 563 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.2158, Adjusted R-squared: 0.2102
## F-statistic: 38.72 on 4 and 563 DF, p-value: < 2.2e-16
It looks like the fit of these selected variables is slightly better for the social distancing data based on not traveling farther than 1km.
Now I also consider “non-work” behavior.
sj_nonworking_by_block <- sj_socialdistancing %>%
filter(weekend == F) %>%
filter(date > shelter_start) %>%
mutate(nonworking = device_count - completely_home_device_count - part_time_work_behavior_devices - full_time_work_behavior_devices) %>%
group_by(origin_census_block_group) %>%
summarize(nonworking_count = sum(nonworking), total_device = sum(device_count)) %>%
mutate(nonworking_percent = nonworking_count*100 / total_device, percent_only_work_home = 100-nonworking_percent) %>%
left_join(sj_1km_testing %>% dplyr::select(`% over 75,000`, `percent less than 30`, `% speaking english > well`, `percent less than 1`, blockgroup), by = c("origin_census_block_group" = "blockgroup"))
# plot against age and income
sj_nonworking_by_block %>%
ggplot(aes(
x = `% over 75,000`,
y = nonworking_percent
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of housholds with incomes over $75,000 (50% AMI) annually",
y = "Percent of devices leaving home for non-work purposes during weekdays since shelter-in-place",
title = "San Jose: Social Distancing and Income, Nonworking Behavior"
)
summary(lm(nonworking_percent ~ `% over 75,000`, sj_nonworking_by_block))
##
## Call:
## lm(formula = nonworking_percent ~ `% over 75,000`, data = sj_nonworking_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -19.922 -4.227 -0.758 3.670 33.628
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 52.99603 1.02994 51.46 <2e-16 ***
## `% over 75,000` -0.16521 0.01588 -10.41 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 6.875 on 566 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.1606, Adjusted R-squared: 0.1591
## F-statistic: 108.3 on 1 and 566 DF, p-value: < 2.2e-16
sj_nonworking_by_block %>%
ggplot(aes(
x = `percent less than 30`,
y = nonworking_percent
)) + geom_point() +
geom_smooth(method=lm) +
labs(
x = "Percent of people younger than 30",
y = "Percent of devices leaving home for non-work purposes during weekdays since shelter-in-place",
title = "San Jose: Social Distancing and Age, Nonworking Behavior"
)
summary(lm(nonworking_percent ~ `percent less than 30`, sj_nonworking_by_block))
##
## Call:
## lm(formula = nonworking_percent ~ `percent less than 30`, data = sj_nonworking_by_block)
##
## Residuals:
## Min 1Q Median 3Q Max
## -22.773 -4.144 -0.345 3.400 32.456
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 35.85635 1.33549 26.849 < 2e-16 ***
## `percent less than 30` 0.17865 0.03385 5.277 1.87e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 7.323 on 567 degrees of freedom
## Multiple R-squared: 0.04682, Adjusted R-squared: 0.04513
## F-statistic: 27.85 on 1 and 567 DF, p-value: 1.871e-07
# multiple regression model
modeltest3 <- lm(sj_nonworking_by_block$nonworking_percent ~ sj_nonworking_by_block$`% over 75,000` + sj_nonworking_by_block$`percent less than 30` + sj_nonworking_by_block$`% speaking english > well` + sj_nonworking_by_block$`percent less than 1`)
summary(modeltest3)
##
## Call:
## lm(formula = sj_nonworking_by_block$nonworking_percent ~ sj_nonworking_by_block$`% over 75,000` +
## sj_nonworking_by_block$`percent less than 30` + sj_nonworking_by_block$`% speaking english > well` +
## sj_nonworking_by_block$`percent less than 1`)
##
## Residuals:
## Min 1Q Median 3Q Max
## -18.758 -4.001 -0.742 3.843 31.685
##
## Coefficients:
## Estimate Std. Error t value
## (Intercept) 44.10456 4.31944 10.211
## sj_nonworking_by_block$`% over 75,000` -0.17101 0.01994 -8.577
## sj_nonworking_by_block$`percent less than 30` 0.08287 0.03928 2.110
## sj_nonworking_by_block$`% speaking english > well` 0.07965 0.04241 1.878
## sj_nonworking_by_block$`percent less than 1` -0.01102 0.04307 -0.256
## Pr(>|t|)
## (Intercept) <2e-16 ***
## sj_nonworking_by_block$`% over 75,000` <2e-16 ***
## sj_nonworking_by_block$`percent less than 30` 0.0353 *
## sj_nonworking_by_block$`% speaking english > well` 0.0609 .
## sj_nonworking_by_block$`percent less than 1` 0.7981
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 6.833 on 563 degrees of freedom
## (1 observation deleted due to missingness)
## Multiple R-squared: 0.1752, Adjusted R-squared: 0.1693
## F-statistic: 29.89 on 4 and 563 DF, p-value: < 2.2e-16
These variables do worse for the percent nonworking metric, which makes sense.